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)$('[data-attribute="value"]');/* html */
<a data-number="123">link</a>
/* js */
$(this).attr("data-number") // returns string "123"
$(this).data("number") // returns number 123 (jQuery >= 1.4.3 only)const dataId = $('#elementId').attr("data-id");//<div id="myElementID" data-myvalue="37"></div>
var a = $('#myElementID').data('myvalue'); //get myvalue
$('#myElementID').data('myvalue',38); //set myvalue<a data-id="123">link</a>
var id = $(this).data("id"); // Will set id to 123
Also in JavaScript:
- asking questions javascript in console
- minify css package.json
- javascript tostring
- invoking jquery validator
- react native init project
- ban someone discord js
- node js catch any errors
- javascript sort by id
- react image upload
- Merging Or Copying Arrays Using Spread Operator
- synchronous vs asynchronous functions javascript
- javascript appendchild at index
- chartjs bar chart hover color
- reusable table in react js
- react replace all line breaks with br
- javascript get elements that exist in two arrays
- gradle json simple dependency
- js add week to date
- javascript add days to date
- bootstrap show modal on page load
- return value of confirm box in javascript
- js loop over array of objects extract value
- change windlow location relitave to current one
- discord.js bad word filter