Karthiga Karthiga - 2 months ago 10
jQuery Question

If the button is disabled i need to show a div after clicking or mouse over the button

Here i have an button which is disabled intially after i click or mouse over the disabled the disable button i need to show one div amd my code is in fiddle.

https://jsfiddle.net/L4aczs0b/

12397

Answer

Here is a working fiddle with your solution. The thing is, that disabled elements don't trigger jQuery events: https://jsfiddle.net/jonva/L4aczs0b/1/

So you need to have an alias element to take the disable element's place in the DOM:

    <div style="display:inline-block; position:relative;">
      <button id="button">submit</button>
      <div style="position:absolute; left:0; right:0; top:0; bottom:0;" id="alias"></div>
   </div>

and then trigger the .fadeIn function on hover of that element

$('#alias').hover( function() {
    $("#d").fadeIn(500);
});
$('#alias').mouseout( function() {
    $("#d").fadeOut(500);
});