I am trying to create a button that will have the same behavior using jQuery as it does with CSS.
HTML:
<br>
<button class="pure-css">Test</button>
<br>
<br>
<br>
This is jQuery :
<br>
<button class="pure-jQuery">Test</button>
CSS:
.pure-css {background-color:#aaa;}
.pure-css:hover{background-color:#ccc;}
.pure-css:active{background-color:#fff;}
jQuery:
// Setting default style via jQuery
{
$(".pure-jQuery").css("background-color","#aaa");
}
// Applying hover style with jQuery
{
$(".pure-jQuery").css("background-color","#ccc");
}
// Implementing active style using jQuery
{
$(".pure-jQuery").css("background-color","#fff");
}
// Returning to default on mouse out if needed
{
// Return to default style if needed
}
View the live example on jsFiddle :