2014-02-08 17 views

回答

1

添加此行您單擊處理後:

$('#stickyheader a:first').addClass('active'); 

還是在HTML中添加class="active"到您的專輯鏈接,頁面加載與適當的類。這樣就不必等待JavaScript添加它。

+0

太謝謝你了。對此,我真的非常感激。現在它工作正常。 – user3281712

1

添加.filter(':first-child').addClass('active').end();到您的活動結合使用鏈接的力量(和不需要用jQuery來重新查詢DOM :)

$(document).ready(function() { 
    $('#stickyheader a').on('click', function() { 
     $(".active").removeClass("active"); 
     $(this).addClass("active"); 
    }).filter(':first-child').addClass('active'); 
}); 

更新的jsfiddle:http://jsfiddle.net/B5dYv/94/

相關問題