如何使用Jquery显示禁用文本框的工具提示

时间:2016-11-15 06:57:42

标签: jquery

使用Jquery

预期ToolTip for Disabled TextBox

这是我的代码

$("#<%=txt_RyotName_R.ClientID%>").hover(function() {
    $(this).css('cursor', 'pointer').attr('title', $("#<%=txt_RyotName_R.ClientID%>").val());
}, function() {
    $(this).css('cursor', 'auto');
});

1 个答案:

答案 0 :(得分:0)

您应该设置title然后绑定事件处理程序。

$("#txt_RyotName_R")
  .attr('title', function(){
      return this.value;
  })
  .hover(function() {
     $(this).css('cursor', 'pointer');
  }, function() {
     $(this).css('cursor', 'auto');
  });

jQuery(function($) {
  $("#txt_RyotName_R")
    .attr('title', function() {
      return this.value;
    })
    .hover(function() {
      $(this).css('cursor', 'pointer');
    }, function() {
      $(this).css('cursor', 'auto');
    });
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="txt_RyotName_R" disabled value="some text">