开发者

Disabled button still clickable in IE8 with jQuery.live('click') event

Sigh

I keep getting strange problems with IE 8.

I have this

    <开发者_如何学JAVAinput name="Btn_Edit" disabled="disabled" id="Btn_Edit" type="button" value="Edit"/>

$(function ()
{
    $('#Btn_Edit').live('click', function ()
    {

        alert('hi');

    });
});

So in every other browser this alert would never get trigger as my button is disabled. In IE 8 it goes into my edit button and triggers the alert.

I don't know why.

http://jsfiddle.net/QgceL/

You can see for yourself it. Just load up IE 8 and try it.

However if I change it to this.

http://jsfiddle.net/YD2eS/

It seems to work. I still dont' know why it brings up a different cursor instead of a pointer.

Anyways the problem seems to be with live click event.


change your selector to:

$('#Btn_Edit[disabled!=true]')

Note that this will NOT work if your selector is $('#Btn_Edit[disabled!=disabled]')

which you can see if you do alert($('#Btn_Edit').attr('disabled')); it will be 'false' when it is not disabled and true when it is disabled.

here is a fiddle page to see it in action: http://jsfiddle.net/QgceL/3/


Change live to click. Yes, it's too weird! I don't know why this happens.


This appears to be a jQuery bug, happening in versions < 1.5.x. This post was done probably when jQuery 1.4 was the latest version, but newer versions do not have this problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜