Questions tagged [custom-data-attribute]

Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.

The HTML5 spec contains a "Embedding custom non-visible data with the data-* attributes" chapter that states the folowing:

A custom data attribute is an attribute in no namespace whose name starts with the string "data-", has at least one character after the hyphen, is XML-compatible, and contains no characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).

[...]

Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.

These attributes are not intended for use by software that is independent of the site that uses the attributes.

1101 questions
-3
votes
1 answer

How to extract data attribute that contains a json string using javascript (no JQuery)

I have the following element below that has a data attribute that contains a json string. I am unable to retrieve the json string, instead it is returning the opening bracket of the json string. Please see…
eddy123
  • 43
  • 11
-3
votes
1 answer

Variable data attribute not working

I have this code: for(var i = 0; i < subjects.length; i++){ $('#container').append('
' + subject[i].title + '
'); } It is not working. This does work: for(var i = 0; i <…
johannes
  • 1,270
  • 12
  • 19
-3
votes
1 answer

How to set data-* attribute of checked radio to class of another element using jquery?

How do I take the data-attribute of a checked radio button and output it inside the class attribute of a different element? Please take a look at the example: body{ background: #eee; } .box{ background: #000; margin: 40px; width:…
Alexander Hein
  • 960
  • 3
  • 19
  • 44
-3
votes
1 answer

Get each numbered data attribute jquery

HTML
I want to get each of these data-thumb-* attributes with…
sansome
  • 19
  • 1
  • 5
-4
votes
1 answer

Selecting multiple data attributes using jquery click() function