I have a select list with values \'all\' and \'custom\'. On select with value \'custom\' a div with class \'resources\' should appear, and if the value is \'all\' it should
You are making this too complicated:
First off, drop the inline onclick
. Since you are using jQuery, attach your handler dynamically.
<div>
<label>Privileges:</label>
<select name="privileges" id="privileges">
<option id="all" value="all">All</option>
<option id="custom" value="custom">Custom</option>
</select>
</div>
<div class="resources" style=" display: none;">resources</div>
Secondly, don't listen for the click and then attach the change
handler. Attach it directly
<script>
jQuery('#privileges').on('change',function(){
if(jQuery(this).val()=='custom'){
jQuery('.resources').show();
} else {
jQuery('.resources').hide();
}
});
</script>