开发者

Disable span does not work on firefox

how to disable a span using jquery/javascript. The script

$('#spanid').attr("disabled", 'disabled');

works fine on IE but doesnt开发者_Python百科 work on firefox.


You cannot disable a <span>. The disabled attribute only works for input elemens. What are you trying to achieve there ?

The only thing I can imagine is that you've got some event bindings on that <span>, to remove those you can call jQuerys .unbind(), .die() and/or .undelegate().

$('#spanid').unbind().undelegate().die();

That would remove any event handler (bound directly or via delegation). The only problem here is, that you would to manually store the event handler functions if you want to "enable" it later on again.


add this to your css

[disabled] {
    pointer-events: none; 
}

check out MDN for browser support. Although IE has only recently supported pointer events, adding disabled to a span in IE makes the span not emit click events.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜