javascript - Why this Variable does not pass correctly in JQuery -


I have a simple joke statement ... and my question is why none of them fails in the world ?

> color is $ (thisCLass) .css ("color", '#' + hex); // written $ (thisCLass). CSS (color attribute, '#' + hex) is written; // works with variable $ (thisCLass) .css ({"color": '#' + hex}); // Written $ (thisCLass) works on .css ({colorAttribute: '#' + hex}); // does not work with variables

Any idea why a failed one?

That's because you do not use a variable to specify a word of the word Can.

In an intent, an identifier can be written with or without the word quotation marks, so it will not be interpreted as a variable in any case. The object will end with the identifier you specify:

  {"colorAttribute": '#' + hex}  

You can specify a variable You can use the property in an object, but then you must first create the object and use the bracket syntax:

  var obj = {}; Obj [colorAttribute] = '#' + Hex; $ (ThisCLass) .css (obj);  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -