jquery - stopping an onclick event if its the tab already selected -


how can stop following code executing if id 1 selected?

any appreciated.

//product tabs     $('#productinfowrap .tab:first').show();         $('#subselect li').click(function() {         var thistop = $(this).position().top;         $('#subselect li').removeclass('current');         var li = (this);         $('.pointer').animate( {'top': thistop}, function() {              $(li).addclass('current');         });         var id = $(this).find("a").attr('href');         $("#productinfowrap > div").fadeout(500).hide();                 $(id).fadein();         return false;     }); 

and html

<ul id="subselect">             <li class="current"><a href="#overview">overview</a><span class="pointer"></span></li>             <li><a href="#applications">applications</a></li>             <li><a href="#technical">technical</a></li>         </ul> 

check presence of "current" class. if has (meaning selected) don't anything.

$('#subselect li').click(function() {     if (!$(this).hasclass('current')){             var thistop = $(this).position().top;             $('#subselect li').removeclass('current');             var li = (this);             $('.pointer').animate( {'top': thistop}, function() {                  $(li).addclass('current');             });             var id = $(this).find("a").attr('href');             $("#productinfowrap > div").fadeout(500).hide();                     $(id).fadein();     }             return false;          }); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -