Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
JS function stopped firing
Message
De
18/10/2014 08:10:15
 
 
À
18/10/2014 02:50:01
Information générale
Forum:
Javascript
Catégorie:
Dépannage
Divers
Thread ID:
01609609
Message ID:
01609615
Vues:
40
J'aime (1)
>>>I created a simple (I thought) javascript function that would allow a DIV block of collapse and expand. It worked once, but as I simplified it more, it stopped working. I have staring at the code for hours, but can not see why it fails.
>>>
>>>-- See attachment --
>>>
>>>Can anyone see where I messed up?
>>You were making a assignment with the if. Should be:
if (oHeader.style.display === 'block') {
>>}
FWIW, if you're doing a lot of this type of DOM manipulation take a look at angular....
>
>It has been awhile since I try modifying this site.
>
>Two questions,
>Should I use two '=', or three as your example indicates?

'==' will use type conversion - usually '===' is safer. See :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators

> And are literal strings best inclosed in single quotes or double quotes?

Doesn't really matter unless you need to embed quotes in the string: e.g.
var x  = "Fred's food";
var y = 'Fred said "Yuk"';
Although, for the general case, as someone said, "Double quotes will wear your shift key out faster" :-}
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform