按鈕上的懸停事件如下。使用jquery懸停在按鈕上?
<div id="common_id">
<div class="button" id="make_larger">
<button type="button">Large</button>
</div>
<div class="button" id="make_small">
<button type="button">Smaller</button>
</div>
<div class="button" id="make_normal">
<button type="button">Normal</button>
</div>
</div>
JQuery的代碼是:
$('#common_id .button').hover(function() {
$(this).addClass('hover1');
}, function() {
$(this).removeClass('hover1');
});
CSS是:
.hover1 {
background-color:Black;
position:relative;
}
當放置鼠標按鈕時,完整的行(從開始頁的端部)是越來越黑甚至按鈕沒有變黑,但它的背景似乎在那一排上是黑色的。 我想讓按鈕在我懸停時變黑。 爲什麼它不起作用?
在此先感謝。
那豈不是更容易使用的CSS' :懸停'假選擇器?使用CSS規則'#common_id .button:hover {}'。 – 2012-08-08 10:58:50