好的,我點擊一次就可以發現多件事情,但我想知道是否有更好的方法來格式化或做到這一點?有沒有更好的方法來格式化多個事件?
<ul><li>Hello</li><li>Welcome</li><li>Howdy</li></ul>
<div class="first">Goodbye</div><div class="second">See ya</div><div class="third">Later Gator</div>
$('li:first-child').click(function(){
$('li:nth-child(2)').removeClass('this');
$('li:nth-child(3)').removeClass('this');
$('.second').hide();
$('.third').hide();
$('li:first-child').addClass('this');
$('.first').show(); });
分別這樣做,我需要點擊其他對象時的相同過程。