Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
尝试这样的事情:
var $ul = $('#alumni_articles_mode_switch'); $ul.on('click','a',function(){ if(!$(this).hasClass('active')){ $ul.find('a').toggleClass('active'); } });
这应该在它们之间切换类,只要只有两个和一个以active. if 逻辑只是为了防止在单击已经处于活动状态的链接时进行切换。
active
jsFiddle 示例在这里。