Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect change of selectmenu in jquery mobile 1.4

I am revisiting JQM after not using it for a few versions.

I have a simple selectbox

<select name="current-option" id="current-option" class="current-option" data-native-menu="false">
        <option>Select Option</option>
        <option value="1">option 1</option>
        <option value="2">option 2</option>
    </select>

I want to be able to detect a change in this select box and then read it's value. It seems as though typical jquery methods don't work and I dont see an event for this in the api: http://api.jquerymobile.com/selectmenu/

like image 623
Cicce19 Avatar asked Feb 13 '23 21:02

Cicce19


1 Answers

Ok, you want to know value of option selected after change event occurs; You should do following:--

$('#current-option').change(function () {
  var optionSelected = $(this).find('option:selected');
  //var optTextSelected = optionSelected.text();
  var optValueSelected = optionSelected.val();
});

I would request you to change name, id and class names for your select tag.

like image 140
Alok Anand Avatar answered Feb 16 '23 10:02

Alok Anand