Here it's my html code
<select class="data">
<option value="This is my test code" data-id='123'/>
</select>
Now I want to access a data attribute in jquery here it's my jquery code
$( ".data" ).change(function() {
var Id = $(this).data("id")
alert("id: "+Id);
});
but when I'm tried this one it's give a undefine value. please help me.
$(this).find(':selected').data("id")optionstags should not be self closed.