Sorry if my question is too simple, but I can't figure it out from the jQuery UI documentation.
How can I determine which option was clicked within a menu? I tried something like this but it didn't work:
var menu = $('#menu');
menu.menu({
select: function(event, ui) {
alert(ui.type);
}
});
What you are missing is the fact that 'ui' is a jQuery object that represents the item you clicked.
so to get the text out of that item you should be using:
var menu = $('#menu');
$(document).ready(function(){
menu.menu({
select: function(event, ui) {
alert(ui.item.text());
}
});
});
That will give you the text of the item.
here is a Fiddle
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