JQuery focus and select on id input field -


demo fiddle

<script> $(document).ready(function () {        document.getelementbyid(introdukt).focus()     document.getelementbyid(introdukt).select() }); </script> <input type="text" size="12" id="introdukt" value="match" style="text-align:center"  /> 

does not focus on field? how correct this?

working fiddle

$(document).ready(function () {       $('#introdukt').focus()     $('#introdukt').select()      //or if want more efficient , use less characters, chain     $('#introdukt').focus().select()  }); 

your weren't using selectors right. check fiddle.

also, changed id in fiddle introdukt had.

also, if you're going use jquery document ready may use jquery selector instead of pure js method.


Comments