我想製作一個按鈕,其行爲與jQuery的行爲與css完全相同。用jQuery模仿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:
/* here I want the defalt position via jQuery */
{
$(".pure-jQuery").css("background-color","#aaa");
}
/* here I want the hover style via jQuery */
{
$(".pure-jQuery").css("background-color","#ccc");
}
/* here I want the active style via jQuery */
{
$(".pure-jQuery").css("background-color","#fff");
}
/* if needed (on mouse out) so one more back to default */
{
/*back to default if needed*/
}
的jsfiddle活生生的例子:
A [從上面的sanjeev代碼演示](http://jsfiddle.net/6DXZD/) – surfmuggle