- // 这样可以
- $('#nav li').click(function() {
- $('#nav li').removeClass('active');
- $(this).addClass('active');
- });
- // 这样更好
- $('#nav li').click(function() {
- $(this).addClass('active')
- .siblings().removeClass('active');
- });
- //该片段来自于http://www.codesnippet.cn/detail/22112012607.html
来源: http://www.codesnippet.cn/detail/22112012607.html