Refresh non native select box

Description

The following code shows how to refresh non native select box.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css">
<script type='text/javascript'
  src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.js"></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!--from  www .  ja  v a2 s . co  m-->
$("#select-1").change(function() {
    var mySelection = $(this).val();
    if (mySelection != null) {
        if (mySelection.indexOf('B') >= 0) {
            $("#option-A").attr("selected", false).trigger("refresh");
        };
    };
});
});//]]>  
</script>
</head>
<body>
  <div data-role="page">
    <div data-role="content">
      <select name="select-1" id="select-1" multiple="multiple"
        data-native-menu="false" />
      <option id="option-A" value='A'>a</option>
      <option id="option-B" value='B'>b</option>
      <option id="option-C" value='C'>c</option>
      </select>
    </div>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Example »




Button
Button Event
Button Icon
Button Text
Checkbox
Collapsible
Date
Dialog
Event
Footer
Form
Header
Icon
Input
Layout
Listview
Listview Divider
Listview Item
Loader
mobile_settings
Navbar
Page
Page Event
Popup
Radio
Select
Slider
Switch
Textarea
Theme