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.