jquery - Disable fade In effect on second click of the element -


i have created custom jquery tab, it's working fine there need small change don't need fadein effect on second click of current tab item means there need $(".tab_container") show normally. how can achieve that?

//custom tab  $(".tab_container").hide(); $('.tab_container:first').show(); $('.tab ul li a').click(function () {     var tab = $(this).attr("href");     $('.tab ul li a').removeclass('active');     $(".tab_container").hide();     $(this).addclass('active');     $(tab).fadein();     return false; }); 

fiddle : http://jsfiddle.net/nikhilvkd/h5maycuc/

i've updated code shown below. i've added variable called "currenttab" , hold current tab name. time when click on tab,checking selected tab variable "currenttab". if condition true, using jquery show() method instead of fadein() show tab. else using fadein() method , update "currenttab" variable newly selected tab name.

var currenttab=$('.tab ul li a:first').attr("href");      $(".tab_container").hide();     $('.tab_container:first').show();     $('.tab ul li a').click(function () {         var tab = $(this).attr("href");         $('.tab ul li a').removeclass('active');         $(".tab_container").hide();         $(this).addclass('active');         if(currenttab==$(this).attr("href"))         {             $(tab).show();         }         else         {              $(tab).fadein();             currenttab=$(this).attr("href");         }         return false;     }); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -