data-value jquery code example
Example 1: jquery get data-id
const dataId = $('#elementId').attr("data-id");
Example 2: jquery data attribute
<a data-number="123">link</a>
$(this).attr("data-number")
$(this).data("number")
Example 3: javascript get data-id attribute
var element = document.getElementById('myDivID');
var dataID = element.getAttribute('data-id');
var dataID = $('myDivID').data('data-id');
Example 4: jquery data
$( "body" ).data( "foo", 52 );
$( "body" ).data( "bar", { isManual: true } );
$( "body" ).data( { baz: [ 1, 2, 3 ] } );
$( "body" ).data( "foo" );
$( "body" ).data();
Example 5: jquery get data attribute
<a data-id="123">link</a>
var id = $(this).data("id");