2011-01-25 3 views
0

ID가 이미 선택된 경우 실행중인 다음 코드를 어떻게 중지 할 수 있습니까?탭이 이미 선택된 경우 onclick 이벤트가 중지됩니다.

도움을 주시면 감사하겠습니다. "현재"클래스의 존재를

//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; 
    }); 

및 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> 
+0

나는?이 불행하게도 그 모두에 도움이된다면 내가 첫 번째 줄에서 현재의 철자를 잘못 않았다 :( – Andy

답변

0

확인합니다. 그것이있는 경우 (의미가 선택됨) 아무 것도하지 마십시오.

$('#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; 

     }); 
+0

을 추가 한 – Andy

+0

작동하지 않은 HTML – derek

+0

예는 :) 난에 그 통지를하지 않았다 않습니다 모든. 고맙습니다! – Andy

관련 문제