Disable select option based on selection
Description
The following code shows how to disable select option based on selection.
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 ww w .j a va2 s . c o m-->
$("#select-1").change(function() {
var mySelection = $(this).val();
if (mySelection !== null) {
if (mySelection.indexOf('B') >= 0) {
$("#option-A").attr("selected", false);
$('#select-1').selectmenu('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>