JQuery Toggle () Set CSS style _jquery

Source: Internet
Author: User
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>
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.