开发者

jquery show/hide button to change tooltip

I have the jquery code bel开发者_StackOverflow中文版ow that changes the text in the button to show/hide but I would also like to change the tooltip/title when the button is hovered over with the mouse to also say show/hide

$('#HideShow').click(function()  
  {  
  if ($(this).text() == "Show")  
   {  
  $(this).text("Hide");  
    }  
   else  
  {  
  $(this).text("Show");  
   };  
   });

How can I use jquery to also change the tooltip/title to show/hide when the button is changed?


$('#HideShow').click(function() {  
      if ($(this).text() == "Show") {  
          $(this).text("Hide").attr("title", "Hide");
       } else {  
          $(this).text("Show").attr("title", "Show");
       }
   });


use the attr command

so $(this).attr("attribute to change", "new value");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜