Radu
Radu

Reputation: 1031

How do i get the selected option from an Jquery UI selectmenu object?

I have a Jquery UI selectmenu object which I have generated dynamically from a database.

I need to get the selected text from it, if it wasn't an Jqueryu UI object I could use this at onChange event like that:

$('#l1').change(function() {
    var selectedText= $('#l1 option:selected').text();
....

How could I get the same value for Jquery UI object? I mention that I can't rely on .val() property because all are 0. I did try this

var selectedText = $(this).find(':selected').text();

without success.

Upvotes: -1

Views: 451

Answers (1)

Radu
Radu

Reputation: 1031

Find out!

It's about how I relate to the on change event.

When I use Jquery UI I have to use:

$('#l1').selectmenu({change: function (event, data) {

instead of:

$('#l1').change(function() {

Now I will try to find why is it that way?

Upvotes: 0

Related Questions