I have a jQuery dialog that I've loaded content into. When I display the dialog the focus is set to the first item displayed. Normally this is not a problem, but I would prefer that none of the items have explicit focus. How can I blur the focus? Or perhaps set it to the dialog itself?
The dialog's HTML ID is "dialog". I've tried $("#dialog").focus()
and $("#dialog :button").blur()
to no avail.
Here's a picture of the dialog:
Calling Blur will trigger the blur event nothing else.
For take the focus out the textbox try $("#dialog").click();
Like this? http://jsfiddle.net/MatthewDavis/Dpk2j/2/
$(document).ready(function () {
// putting a value into a button we don't want focused
$('#mybutton').val('Here I am.');
// doing something visual to see when focus happens more clearly
$("input").focus(function () {
$(this).next("span").css('display','inline').fadeOut(1000);
});
// focus on the right input
$('#dialog').focus();
});
Try this:
open:function(){
$(this).attr('tabindex',-1).css('outline',0).focus();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.