Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is wrong with this line?
Message
De
08/12/2015 13:42:15
 
 
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01628592
Message ID:
01628663
Vues:
35
Seems like we are making it complicated. JS returns an undefined or null when an object does not exist, but it in no way is considered an error, and code execution will continue. But if you want to work with that object, you only need a simple IF:

if (document.getElementById(myVar)) {
alert('hello') ;
. . . . do some more stuff;
}

>What could be wrong with the following javascript line?
>
>
>var MyVar = document.getElementById("MyInputText").value;
>
>
>I have nothing in the javascript but the above line and Alert() after this line.
>If I comment the above line, the Alert() fires. Otherwise, Alert() never fires. So I think there is something wrong with the above line.
>But what?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform