如何在父div被關注時改變div內元素的類別?當div被聚焦時,改變div中元素的類別?
當我在
<div id="window" class="fenster"><a class="bye"></a></div>
類的變化爲hello積極樣?
如何在父div被關注時改變div內元素的類別?當div被聚焦時,改變div中元素的類別?
當我在
<div id="window" class="fenster"><a class="bye"></a></div>
類的變化爲hello積極樣?
假設通過集中你的意思是鼠標是它,你可以使用jQuery?
$('#window').mouseover(function() {
$('a.bye', this).removeClass('bye').addClass('hello');
});
如果你想重置類,當你將鼠標移出:
$('#window').hover(function() {
$('a.bye, a.hello', this).toggleClass('bye').toggleClass('hello');
});
更像是當我點擊它時,就像當你在操作系統中出現一個新窗口一樣 – 2011-04-08 11:05:53
@Jeremy你可以改變第一個例子使用.click而不是.mouseover。這可能會做你想要的。 – 2011-04-08 12:36:06
你可以做到這一點沒有jQuery的:
document.getElementById('window')。setAttribute('class','newclassname');
「聚焦」是什麼意思? – Twelve47 2011-04-08 10:54:03