Toggle ()
Switches the visible state of an element. If the element is visible, switch to hidden. If the element is hidden, switch to visible. --------------------------------- Example
Switch the visible status of all paragraphs.
HtmlCode:
<P> Hello </P> <P style = "display: none"> hello again </P>
Jquery code:
$ ("P"). Toggle ()
Result:
<P tyle = "display: none"> Hello </P> <P style = "display: Block"> hello again </P> ---------------------------------
Set the background image to highlight the effect of transparency <Head>
<Title> toggle () </title>
<Style type = "text/CSS">
<! --
Body {
Background: url(bg.jpg );
Margin: 20px; padding: 0px;
}
IMG {
Border: 1px solid # ffffff;
}
-->
</Style>
<Script language = "JavaScript" src = "jquery. Min. js"> </SCRIPT>
<Script language = "JavaScript">
$ (Function (){
$ ("IMG"). Toggle (
Function (oevent ){
Certificate (oevent.target).css ("opacity", "0.5 ");
},
Function (oevent ){
Certificate (oevent.target).css ("opacity", "1.0 ");
}
);
});
</SCRIPT>
</Head>
<Body>
</Body>