Reputation: 15856
I have pulldown menu defined like this:
<select id="select_command" ><option data-syntax="blabla"></option></select>
How can I retrieve the data-syntax
of the currently selected option upon clicking some button ?
Upvotes: 0
Views: 78
Reputation: 115282
Try this,
$('.button').click(function(){
var sel=$('option').filter(':selected').data('syntax');
alert(sel);
});
Upvotes: 2
Reputation: 145478
$('#some_button').on('click', function() {
var syntax = $('#select_command :selected').data('syntax');
// ...
});
Upvotes: 3