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:
disabled="disabled" does not work in ie6/7 when you use jQuery to change the attribute dynamically.
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);
精彩评论