JQuery enables multiple buttons to change color. jquery click to change color.
The code for this small special effect is very simple, so we will not explain it much, but directly provide the source code.
JQuery code:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
// Load the event
$ (Function (){
Var collection = $ (". flag ");
$. Each (collection, function (){
$ (This). addClass ("start ");
});
});
// Click the event
Function dj (dom ){
Var collection = $ (". flag ");
$. Each (collection, function (){
$ (This). removeClass ("end ");
$ (This). addClass ("start ");
});
$ (Dom). removeClass ("start ");
$ (Dom). addClass ("end ");
}
</Script>
Css code:
Copy codeThe Code is as follows:
<Style type = "text/css">
. Start
{
Cursor: pointer;
Color: Green;
}
. End
{
Cursor: pointer;
Color: Red;
}
</Style>
Html code:
Copy codeThe Code is as follows:
<Span class = "flag" onclick = "dj (this)"> LoveOne </span>
<Span class = "flag" onclick = "dj (this)"> LoveTwo </span>
<Span class = "flag" onclick = "dj (this)"> LoveThree </span>
<Span class = "flag" onclick = "dj (this)"> LoveFour </span>
Isn't it very simple? The special effects are also very fun. You can play them freely and the scalability is still very strong. If you do anything more fun, please let me know.