You make it too complicated:
First release the built-in onclick
. Since you are using jQuery, dynamically attach the handler.
<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, do not listen to 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>
Steve source share