2011-03-24 6 views
0

나는 JQuery와 함께 새로운 해요,이JQuery와 : 링크 제목 속성 unchange

$("#trigger").click(
    function(){ 
     $("#pnel-menu").toggle("slow"); 
     $(this).toggleClass("active"); 
     $(this).attr("title", "Open Panel"); 
    }, function() { 
      $(this).attr("title", "Close Panel"); 
      return false; 
}); 

HTML에 문제가

<div id="pnel-menu"> 
    menu 
</div> 
<p class="slidebar"> 
    <a id="trigger" title="" href="#"></a> 
</p> 
<div id="pnel-cont"> 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit 
</div> 

내가 무엇을 좋아하는 경우 dinamically .trigger 제목을 변경하는 것입니다 # pnel-menu를 열거 나 닫으려면 clik하십시오.

하지만 변경되지 않습니까? 사람이 몇 가지 단서를 제공 할 수 있습니다 않습니다, 감사하기 전에 :

답변

2

이 시도 :

$("#trigger").click(function(){ 
    var that = $(this); 
    $("#pnel-menu").toggle("slow"); 
    that.toggleClass("active"); 
    that.attr("title", (that.hasClass("active")?"Close":"Open") + " Panel"); 
}); 
1

난 당신이

$("#trigger").click(function(){ 
     $("#pnel-menu").toggle("slow"); 
     $(this).toggleClass("active"); 
     if($(this).attr("title") == "Open Panel"){ 
       $(this).attr("title", "Close Panel");  
       return false; 
     } 
     else 
       $(this).attr("title", "Open Panel"); 
     }); 

희망이 작품 구분자로 ,로 두 가지 기능을 사용한다고 생각하지 않습니다^