Title, the code is on.
<HTML><Head><title>Denotoggle</title><style>#box{width:100px;Height:100PX;Background-color:#ddd}. Show{Visibility:Hidden;}</style><Scriptsrc= "Http://libs.baidu.com/jquery/1.8.2/jquery.min.js"></Script><!--//java Script Method -<Scripttype= "Text/javascript">window.onload= function() { functionToglemain () {varobj=document.getElementById ("Box"); if(Obj.classname== "") {Obj.classname= "Show"; } Else{obj.classname= ""; } } varClickbutton=document.getElementById ("Toggle"); Clickbutton.onclick=Toglemain;//The onclick method clicks on the button with the Click event, actually performing the OnClick method first, but asking what, and also starting the Click event? This is because the click event is triggered internally by the OnClick method. }</Script><!--//jquery Toggle Method -<Scripttype= "Text/javascript">$ (document). Ready (function() { $(". BTN1"). Click (function() { /*$ ("P#box"). Toggle ();*/ $("#box"). Toggleclass ("Show"); }); });</Script></Head><Body> <DivID= "box"></Div> <ButtonID= "Toggle">JavaScript Toggle</Button> <Buttonclass= "BTN1">JQuery Toggle</Button></Body></HTML>
We also ask you to add a jquery addclass and remove to implement the hidden display code.
The hiding and displaying of JavaScript and jquery methods