开发者

jquery disabled=disabled not working in safari

I have some code that disabled a button, using jquery it does:

$('#fishID').att开发者_运维百科r('disabled', 'disabled');

This seems to work in every browser (IE6, IE7, 8, 9, Chrome, Firefox) except Safari where it does not disable the button.

Should I be setting it to 'disabled', 'true' ? What's the difference?

Is there a quirk with Safari that might explain this not working?


in jQuery 1.6+ you should use .prop('disabled', true);, this should work for all.


No, the probably may be jQuery. I believe this is fixed in 1.6.

http://ejohn.org/blog/jquery-16-and-attr/


I have spent time on this. Here is what I have learned:

  1. disabled="disabled" does not work in ie6/7 when you use jQuery to change the attribute dynamically.

  2. The only way around this is to clone the select, add the disabled attribute (or remove it), then append back.

Example:

//clone dropdown and append for ie support
var _parent = $("#selectElement").parent();
var _clone = $("#selectElement");
$(_clone).attr("disabled","true");
$("#selectElement").remove();
$(_parent).append(_clone);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜