【问题标题】:jquery show/hide button to change tooltipjquery 显示/隐藏按钮以更改工具提示
【发布时间】:2011-09-30 23:53:05
【问题描述】:

我有下面的 jquery 代码,它将按钮中的文本更改为显示/隐藏,但我还想在鼠标悬停在按钮上时更改工具提示/标题以显示/隐藏

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

如何使用 jquery 来更改工具提示/标题以在按钮更改时显示/隐藏?

【问题讨论】:

    标签: javascript jquery button toggle


    【解决方案1】:
    $('#HideShow').click(function() {  
          if ($(this).text() == "Show") {  
              $(this).text("Hide").attr("title", "Hide");
           } else {  
              $(this).text("Show").attr("title", "Show");
           }
       });
    

    【讨论】:

      【解决方案2】:

      使用 attr 命令

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-28
        • 1970-01-01
        • 2019-10-26
        相关资源
        最近更新 更多