jQuery select change show/hide div event

前端 未结 9 1480
失恋的感觉
失恋的感觉 2020-11-27 17:34

I am trying to create a form which when the select element \'parcel\' is selected it will show a div but when it is not selected I would like to hide the div. Here is my mar

9条回答
  •  温柔的废话
    2020-11-27 18:20

    Try this:

     $(function () {
         $('#row_dim').hide(); // this line you can avoid by adding #row_dim{display:none;} in your CSS
         $('#type').change(function () {
             $('#row_dim').hide();
             if (this.options[this.selectedIndex].value == 'parcel') {
                 $('#row_dim').show();
             }
         });
     });
    

    Demo here

提交回复
热议问题