开发者

onclick checkbox , hide a div and show another div

开发者 https://www.devze.com 2023-04-01 12:25 出处:网络
I havent actually done any code for 开发者_开发问答this, was searching on internet and found this article:

I havent actually done any code for 开发者_开发问答this, was searching on internet and found this article:

http://iamzed.com/jquery/showhidediv.html

Was thinking, for our purposes...

Part of a form we are making, normal display. is like this:

onclick checkbox , hide a div and show another div

And checking the checkbox, hides the above div and shows this div..

onclick checkbox , hide a div and show another div


I tried to emulate what I saw in the pictures in fiddle. It's not styled but it has the functionality you are looking for.


Assuming you have proper html structure, that everything you want to hide is in div with id yourOldContent and what you want to show is in div with id yourDivWithNewContent (which is initially hidden with display: none;), and the checkbox has id checkboxId, you can use following code:

 $('#checkboxId').click(function(){
  $('#yourDivWithNewContent').toggle();
  $('yourOldContent').toggle();
});


$("#checkbox").click(function(){
   if ($(this).is(':checked')){
      $("#box1").show();
      $("#button_feature").show();
      $("#button_normal").hide();
   }
   else{
      $("#box1").hide();
      $("#button_feature").hide();
      $("#button_normal").show();
   }
});
0

精彩评论

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