开发者

How to show div upon clicking drop down box

I have a开发者_Go百科 drop down box with yes and no values. By default it's set to 'No' however when we select the value of yes another div should appear. Please help


$('#IdOfYourDropDown').change(function(){
    if($(this).val() == 'Yes'){
        $('#IdOfYourDiv').show();
    }
    else{
        $('#IdOfYourDiv').hide();
    }
});


$('#my_dropdown_id').bind('change', function(){
   switch($(this).val().toLowerCase()){
      case 'yes':{
          $('#my_show_id').show();
          break;
      }
      case 'no':{
          $('#my_show_id').hide();
          break;
      }
   }
});

You can extend that switch statement with any other value you might want to test for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜