/* 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)
alert($('#outer').html()); // alerts <div id="mydiv" data-myval="10"> </div>
var a = $('#mydiv').data('myval'); //getter
$('#mydiv').attr("data-myval","20"); //setter
alert($('#outer').html()); //alerts <div id="mydiv" data-myval="20"> </div>
/* 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)
$("ul").find(`[data-slide='${current}']`)
<a data-id="123">link</a>
var id = $(this).data("id"); // Will set id to 123
$('input[type=radio][name=supplier_price]').change(function () {
var $id = $(this).val(),
$price = $(this).data('price'),
$intend_price = $(this).data('intend-price'),
$product__month_price = $('#product__month_price'),
$product_price = $('#product_price');
console.log($price, $intend_price);
});
<div id="123" data-img-flag="1">
<image src="abc.png">
</div>
<div id="432" data-img-flag="0">
<image src="abc.png">
</div>
<script>
alert($(popImgId).data('img-flag')); // when we use data function to get the data attribute value wll get all time value loaded at the time of DOM loaded
alert($(popImgId).attr('data-img-flag')); // value will get lates. If we change/update value using jquery will get updated value
</script>
$("ul[data-slide='" + current +"']");