Js code
Code directly:
| The code is as follows: |
Copy code |
<Script type = "text/javascript"> Function showorhiddenme (){ Var t_div = document. getElementById ("test "); If (t_div.style.display = "block "){ T_div.style.display = "none "; } Else if (t_div.style.display = "none "){ T_div.style.display = "block" } } </Script> |
Let's look at the jquery example.
| The code is as follows: |
Copy code |
<Script type = "text/javascript"> $ (Function (){ Alert((('{a'}.css ('display ')); Alert((('% B '%.css ('display ')) }) </Script> <Div id = "a"> a </div> <Div id = "B" style = "display: none"> B </div> |
Of course, jquery toggle is the easiest way to hide div display.
| The code is as follows: |
Copy code |
<Html> <Head> <Script type = "text/javascript" src = "/jquery. js"> </script> <Script type = "text/javascript"> $ (Document). ready (function (){ $ (". Btn1"). click (function (){ $ ("P"). toggle (1000 ); }); }); </Script> </Head> <Body> <P> This is a paragraph. </p> <Button class = "btn1"> Toggle </button> </Body> </Html> |