Toggle ()
Toggles the visible state of the element.
If the element is visible, switch to hidden, and if the element is hidden, toggle to visible.
---------------------------------
Example
Toggles the visible state of all paragraphs.
HTML Code:
<p>hello</p><p style= "Display:none" >hello again</p>
JQuery Code:
$ ("P"). Toggle ()
Results:
<p tyle= "Display:none" >hello</p><p style= "Display:block" >hello again</p>
Set the background picture to highlight the effect of transparency
Copy Code code as follows:
<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) {
$ (oevent.t arget). CSS ("opacity", "0.5");
},
Function (oevent) {
$ (oevent.target). CSS ("opacity", "1.0");
}
);
});
</script>
<body>
</body>