[英]highlight both page and matching tab in jquery
我有一個標簽導航鏈接(tab1,tab2,tab3),頁面底部有一個每個標簽的頁面鏈接導航。
標簽突出顯示
$(document).ready(function(){
var str=location.href.toLowerCase();
$(".tabs li a").each(function() {
if (str.indexOf(this.href.toLowerCase()) > -1 ) {
$("li.highlight").removeClass("highlight");
$(this).parent().addClass("highlight");
}
});
})
用於頁面突出顯示
$(document).ready(function(){
var str=location.href.toLowerCase();
$(".paging li a").each(function() {
if (str.indexOf(this.href.toLowerCase()) > -1 ) {
$("li.hp").removeClass("hp");
$(this).parent().addClass("hp");
}
});
})
雖然每個功能都正確突出顯示頁面鏈接和標簽鏈接,但如何突出顯示當前標簽(點擊頁面鏈接后)和當前頁面? 我可以使用上述功能嗎?
謝謝!
是的你可以使用相同的函數只需綁定一個函數來調用上面的函數到頁面鏈接標簽給一個html元素的id,例如<Div id="myId"></Div>
並嘗試這個
$("myId").live('click',function(){
// call whichever function you want to
}) ;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.