My page looks like
<html>
<head> ... </head>
<body>
... content ...
<input type="text" id="ct_one" name="ct_pet[]" value="" />
... content ...
<script&g开发者_开发知识库t; ... load jquery and jquery_ui ... </script>
</body>
</html>
Thanks in advance!
PeterYou can put a script right after the element, that sets focus to it. That would set focus at the earliest possible moment, i.e. right after the element is created.
<input type="text" id="ct_one" name="ct_pet[]" value="" />
<script type="text/javascript">
document.getElementById('ct_one').focus();
</script>
Assign value 0 to attribute tabindex for your input field.
http://www.w3.org/TR/html4/interact/forms.html#adef-tabindex
the accepted answer here seems to be "the really fastest" :)
Set input field focus on start typing
JSFiddle example
精彩评论