JQuery implements the method of changing the background color of the Div layer by moving the mouse over the Div Layer

Source: Internet
Author: User

JQuery implements the method of changing the background color of the Div layer by moving the mouse over the Div Layer

This article mainly introduces jQuery's method of changing background color by swiping the mouse over the Div layer. It involves the use of hover and addClass methods in jQuery and has some reference value. For more information, see

 

 

This document describes how to change the background color of a Div layer by swiping the mouse over jQuery. Share it with you for your reference. The specific implementation method is as follows:

 

The Code is as follows:

<Html>
<Head>
<Title> jQuery allows you to adjust the background color of a layer by passing through the Div layer. </title>
<Style type = "text/css">
. Divbox {
Height: 300px;
Width: 200px;
Background: # ffffff;
Border: solid 1px # ccc;
Float: left;
Margin-right: 10px;
}
. DivOver {
Background: # eff8fe;
Border: solid 1px # d2dc4;
}
# Zztj {color: # ffffff ;}
# Zztj a, # zztj a: link, # zztj a: visited, # zztj a: active {color: # ffffff ;}
# Zztj a: hover {color: # ffffff ;}
</Style>
<Script src = "/images/jquery. js"> </script>
<Script language = "javascript">
$ (Function (){
// Change the div class to divOver when the mouse slides in.
$ ('. Divbox'). hover (function (){
$ (This). addClass ('vover ');
}, Function (){
// Remove the divOver style when the mouse leaves
$ (This). removeClass ('vover ');
}
);
});
</Script>
</Head>
<Body>
<Div id = "menu">
<Div class = "divbox"> Block A </div>
<Div class = "divbox"> Block B </div>
<Div class = "divbox"> Block C </div>
</Div> <br> tip: If the preview effect is not displayed, <font color = red> refresh the page </font> because the remote jquery plug-in is called, it must be loaded before running.
</Body>
</Html>

 

I hope this article will help you with jQuery programming.

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.