此代码将“活动”类添加到菜单(.active)并将其删除.
它还为活动链接添加了一个span类:< span class =“filet_menu”>
它就像一个魅力.
但是我怎样才能删除这个span类?我试过打开但是它没有删除span类“unwrap”.
你能帮忙吗?
$("#menu a").click(function() {
$("#menu a").each(function(){
$(this).removeClass("active");
//Don't work :
//$(this).unwrap('');
//$(this).contents().unwrap();
//$('(this) > .active').unwrap();
});
$(this).addClass("active");
$(this).wrapInner('');
});
CSS:
.active
{
color:#32c0ce !important;
}
.filet_menu
{
border-bottom: 2px solid #32c0ce;
padding-bottom:2px;
}
HTML: