Answers for "get data tag"

6

jquery get data attribute value

/* html */
<a data-id="123">link</a>

/* js */
$(this).attr("data-id") // returns string "123"

$(this).data("id") // returns number 123 (jQuery >= 1.4.3 only)
Posted by: Guest on October-28-2020
12

js get data attribute

var element = document.querySelector('.element');
var dataAttribute = element.getAttribute('data-name');
// replace "data-name" with your data attribute name

console.log(dataAttribute);
Posted by: Guest on February-03-2020
0

javascript get data-id attribute

//get data-id attribute in plain Javascript
var element = document.getElementById('myDivID');
var dataID = element.getAttribute('data-id');

//get data-id using jQuery
var dataID = $('myDivID').data('data-id');
Posted by: Guest on July-31-2019
0

data id tag

var dataId = $(this).attr("data-id");
Posted by: Guest on March-11-2020
0

get data tag

Syntax:
<data value=" "> Write your text here </data>
Example:
<body>
      <h2>Example for HTML Data Tag</h2>
      <p>Subjects Name:</p>
  		 <ul>
         <li> <data value="1000">Maths</data></li>
         <li> <data value="1003">Science</data></li>
         <li> <data value="1009">English</data></li>
         </ul>
   </body>
Posted by: Guest on August-23-2021

Browse Popular Code Answers by Language