Laravel & Php

jQuery select change show/hide div event


jQuery select change show/hide div event

Below is a code snippet for showing a div by changing a select value

<select class="form-control" id="selectedValue">
<option value="one">One</option>
<option value="two">two</option>
</select>

<div id="showDiv" style="display:none">
<p>This is section one</p>
</div>

<script type="text/javascript">
      $(document).ready(function() {
         $('#selectedValue').on('change', function() {
            if (this.value == 'one') {
               $('#showDiv').show();
            } else {
               $('#showDiv').hide();
            }
         });
      });
   </script>

jquery Html Java Script
Share with Friends

Like this chef? Share with friends..