Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

highlight both page and matching tab in jquery

I have a tab navigation link(tab1, tab2, tab3) and the bottom of the page there is a page link navigation for each tabs.

for tabs highlight

$(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");
         }
      });
})

for page 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");
      }
    });            
 }) 

although a page link and a tab link were highlighted correctly for each functions how can i highlight current tab(after clicking page link) and current page at once? can i use above functions?

thanks!

like image 507
SFernando Avatar asked Aug 29 '12 06:08

SFernando


1 Answers

yes you can use same functions just bind a function to call the above functions to the page link tag give an id to an html element eg <Div id="myId"></Div> and try this

$("myId").live('click',function(){
  // call whichever function you want to
 }) ;
like image 110
CognitiveDesire Avatar answered Oct 17 '22 13:10

CognitiveDesire