Focus element in ThickBox March 24, 2009

I faced with a problem focusing element in thickbox popup. I open login form using thickbox and want to take a focus on the first element of the form. Though the following code does look to be working:

$(document).ready(function() {
    $("input[name='username']").focus();
});

But there is a little trick. If you make a small 100ms delay in focus() call it works:

$(document).ready(function() {
    setTimeout("$(\"input[name='username']\").focus();", 100);
});
2 Comments
derp April 1st, 2010

thanks!

Ismael July 29th, 2010

Thank you!!!! I was getting really upset because I couldn’t focus a simple textbox, but I thought… “could it be thickbox?” and I found your answer later, thank you! :)

Leave a Reply