javascript - jQuery attr() method to create a data dash attribute -
I am trying to understand why attribute for adding data-attributes (let's say an image) Name is required in quote I know that it needs to be done, but if a student asked me why I would not have the correct answer then take two examples below.
1.) I am exploring an explanation why dash is a problem.
2.) Is there a way to avoid it, so you do not need to put it in quotation marks? / P>
This does not work: This works 3) The argument passed to the ARR () method is the true meaning of an object? 1). In object literals, the 2.) No, you have to use quotes. 3.) Yes. 4.) Yes, see 1.
$ ("img"). Attr ({alt: "picture of my cat", data -item: "pet", data-color: "orange",});
$ ("img"). Attr ({alt: "photo of my cat", 'data-object': "pet", 'data-color': "orange",});
4. Is this object just a rule in the literal syntax which is not allowed to have a dash? - symbol is not allowed as an identifier because it has zero operator in JavaScript.
Comments
Post a Comment