how to add data attribute in jquery code example
Example 1: jquery set data attribute value
//<div id="myElementID" data-myvalue="37"></div>
var a = $('#myElementID').data('myvalue'); //get myvalue
$('#myElementID').data('myvalue',38); //set myvalue
Example 2: jquery data attribute
/* 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)
Example 3: set data attribute with a string jquery
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>