Jquery toggle () sets CSS styles

Source: Internet
Author: User

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.
Html Code :
<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 Copy code The Code is 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 ){
Certificate (oevent.target).css ("opacity", "0.5 ");
},
Function (oevent ){
Certificate (oevent.target).css ("opacity", "1.0 ");
}
);
});
</SCRIPT>
</Head>
<Body>

</Body>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.