0

After rendering code in browser the anchor tag is generated as

<a onclick="alert();" id="ctl00_RightContent_lnkSaveTop" title="Select Mail then Click to Send..." class="btn btn-u" data-rel="tooltip" data-container="body" data-toggle="popover" data-placement="top" data-content="Select Mail then Click to Send..." href="javascript:__doPostBack('ctl00$RightContent$lnkSaveTop','')" style="float: right" data-original-title="Send Email" disabled="disabled">
  Send Mail
</a>

I have written jquery as below lines of code

$(document).ready(function () {
  $('#<%= lnkSaveTop.ClientID%>').click(function () {
    if ($(this).is(':disabled')) {
      alert('No need to click, it\'s disabled.');
    }
  });
});

Basically I want that if disabled button is clicked, then the tooltip should be displayed.

jahller
  • 2,299
  • 1
  • 28
  • 30

2 Answers2

0

Try:

 if ($(this).attr('disabled') === "disabled") {
      alert('No need to click, it\'s disabled.');
    }

if you intend to use readonly attribute, it's the same, replace 'disabled' with 'readonly '

Anudeep Rentala
  • 150
  • 1
  • 6
0

What you can do is have a custom data attribute on your input button which is a blank string. Then when the mouse enters the button you remove the title and place it inside of your empty data attribute and remove title, this will stop the tooltip from appearing. You then listen for the click even on the input and then move copy the text from the data attribute to the title and that should do the trick

Here is my jsFiddle : https://jsfiddle.net/44vof888/

jQuery

$(function () {
    $('input').mouseenter(function () {
        $(this).data('title', this.title)
        this.title = '';
    });

    $('input').on('click', function () {
        this.title = $(this).data('title');
    });
});

html

<input type="button" data-title="" value="Hello" title="Half an update" readonly="readonly"></input>
Canvas
  • 5,553
  • 9
  • 51
  • 97