2011-04-08 47 views

回答

2

假設通過集中你的意思是鼠標是它,你可以使用jQuery?

$('#window').mouseover(function() { 
    $('a.bye', this).removeClass('bye').addClass('hello'); 
}); 

如果你想重置類,當你將鼠標移出:

$('#window').hover(function() { 
    $('a.bye, a.hello', this).toggleClass('bye').toggleClass('hello'); 
}); 

JSFiddle Example

JSFiddle Example using only javascript

+0

更像是當我點擊它時,就像當你在操作系統中出現一個新窗口一樣 – 2011-04-08 11:05:53

+0

@Jeremy你可以改變第一個例子使用.click而不是.mouseover。這可能會做你想要的。 – 2011-04-08 12:36:06

1

你可以做到這一點沒有jQuery的:

document.getElementById('window')。setAttribute('class','newclassname');

相關問題