I am unable to catch the data-attribute after the applying jQuery UI select menu on it.
How is it possible to get the data?
HTML:
<select class="drpmnu">
<option data-timings="something1">(01)</option>
<option data-timings="something2">(02)</option>
</select>
JavaScript:
$(".drpmnu").selectmenu({
change: function( event, ui ){
console.log($(this).data('timings'));
}
});
http://jsbin.com/hicura/1/edit?html,console,output
this refers to the selectmenu itself, not the object in it. You need to use ui.item for that:
$(".drpmnu").selectmenu({
change: function( event, ui ){
console.log($(ui.item.element).data('timings'));
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With