detect change of selectmenu in jquery mobile 1.4

Cicce19 picture Cicce19 · Feb 5, 2014 · Viewed 8.2k times · Source

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/

Answer

Alok Anand picture Alok Anand · Feb 5, 2014

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.