I am using a jQuery Plugin select2.js. how can i select data attribute of selected option using jQuery.
here is the code
<select class="select2">
<option data-id="1" value="2"> CASE 1 </option>
<option data-id="2" value="2"> CASE 1 </option>
<option data-id="3" value="2"> CASE 1 </option>
</select>
$(document).ready(function(){
$('.select2').select2();
$('.select2').click(function(){
//alert($(this).val());
});
});
How i can get data-id of selected option using jQuery.