Reputation: 3369
Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus
jQuery threw the above error on IE8.
I'd like to be able to detect if the browser supports focus on disabled elements (an input
in my case), and store it in jQuery.support
.
How would I do this?
A plain JS solution would be fine, but I don't want to use browser sniffing (jQuery.browser
, etc).
Would using dispatchEvent()
be a good way to go?
Upvotes: 0
Views: 450
Reputation:
I suppose you could just try
, catch
exactly that (focusing a disabled element), and store a value in support
if anything borks.
var test = $('<input disabled/>');
$(document.body).append(test);
try{
test.focus();
}catch(e){
//no support, do your thing
//...
}
//clean up test element
test.remove();
Upvotes: 4