开发者

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜