jQuery does not .focus

I have a jQuery toggle div that appears onclick of the link.

<p><a id="slick-toggle1" href="#">Yes, enroll me today!</a></p> 

<div id="login"> 
<!--#include virtual="LoginPopup.asp"--> 
</div>

in LoginPopup.asp i can not get the focus to go to the first field of username

$(document).ready(function() { 

$('#slickbox1').hide(); 

$('a#slick-toggle1').click(function() { 
$('#login').toggle(300); 
return false; 
}); 

//#SecLoginP is ID of form 

$("#SecLoginP :input:visible:enabled:first").focus(); 

});  

when the toggled DIV appears, i can see the cursor in the field, but when it finishes loading, it dissapears...?

any ideas?

Answers


That shouldn't actually call focus on the underlying HTML element.

Try

$('#SecLoginP ...').get(0).focus();

This is confusing, but $(elem).focus() triggers the focus events bound on the element, rather than hitting the actual HTML element's focus method.


Need Your Help

Faster code for cuting 'good row range' from sh2 to sh1?

excel vba excel-2003

Does it exist any way to make this code run faster as it goes one row by one row ?

Any AOP support library for Python?

python aop

I am trying to use some AOP in my Python programming, but I do not have any experience of the various libraries that exist.