Find it:

Tuesday, July 9, 2013

Show hide Div based on select value

Practical JQuery script to show a Div based on a select value:


<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(){
  var Privileges = jQuery('#privileges');
var select = this.value;
Privileges.change(function () {
   if ($(this).val() == 'custom') {
$('.resources').show();
   }
   else $('.resources').hide();
});
});
</script>
<div>
    <label>Privileges:</label>
    <select name="privileges" id="privileges" class="" onclick="craateUserJsObject.ShowPrivileges();">
        <option id="all" value="all">All</option>
        <option id="custom" value="custom">Custom</option>
    </select>
</div>
<div class="resources" style=" display: none;">resources</div>

Just needed JQuery 1.9.1 

No comments:

Post a Comment