我有這個小小的jQuery代碼工作,但有一件事我無法弄清楚。點擊我的infocontent菜單後,h1:hover就消失了。我如何獲得懸停功能?如何使用jQuery重置顏色後恢復懸停?
HTML:
<div class="infocontent"><h1>Wat?</h1></div>
<div class="infocontent"><h1>Van/ voor wie?</h1></div>
<div class="infocontent"><h1>Akties</h1></div>
<div class="infocontent"><h1>Met wie?</h1></div>
CSS:
.infocontent {
width: 120px;
height: 120;
float: left;
}
.infocontent h1 {
width: 100%;
font-size: 24px;
text-transform: uppercase;
color: #999;
}
.infocontent h1:hover { color: #000; }
的jQuery:
$('.infocontent h1:first').css('color', '#000');
$(".infocontent h1").on("click", function() {
$('.infocontent h1').css('color', '#999');
$(this).css('color', '#000');
});
工程就像一個魅力:) –
我更新了鏈接添加背景顏色支持,以及看到你的評論。做了一些可選的更改,似乎更有趣。 – FiLeVeR10
謝謝,但我會堅持我的原始代碼的背景,儘管你的版本有更少的代碼,'因爲我昨天開始使用jQuery,這將花費我一些時間來調整你的代碼,我想要的東西改變的方式: P 這是我使用它的網站[鏈接](http://payitforwardarnhem.nl/index4.php): –