I am trying to enable dropdown when the checkbox is checked. But when I do so... It didn't working. Pls help me out here. HTML :
<label class="checkbox-inline">
<input type="checkbox" value="" id="onstage">On Stage
</label>
<div class="col-md-9">
<select name="occupation" id="occupation" multiple="multiple" disabled="disabled">
<option value="Actor">Actor</option>
<option value="Supervisor">Supervisor</option>
<option value="Extra">Extra</option>
</select>
JQuery :
<script type="text/javascript">
$(function(){
$("#onstage").click(function(){
if($(this).is(":checked")){
$("#occupation").removeAttr("disabled");
$("#occupation").focus();
} else {
$("#occupation").attr("disabled", "disabled");
}
});
});
</script>
If you are using jquery
3.2.1
then your code must work.Check once
1) You don't have error in other js code(check console for error)
2) Make sure id must be unique so you must have
onstage
andoccupation
only one time in documentEDIT as per your comment you are using
bootstrap multiselect
So you need to enable and disablemultiselect
attribute chcgae your code like this: