[英]JQuery: Making a tab active
下面的代码可以解决您的问题。
// when clicking a link inside the sub-navigation list
$('#sub-navigation a').click(function(){
// first remove the selected class from the active one
$('#sub-navigation li.selected').removeClass('selected');
// then find the parent li of the clicked element and add the selected class
$(this).parents('li').addClass('selected');
});
(它已在您的示例页面上经过测试,并且可以按预期工作。)
$("a").click(function(e) {
$("a.selected").removeClass("selected");
$(this).addClass("selected");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.