Javascript Focus() function not working -
i have textbox want set focus on, doesn't work.
document.getelementbyid("txtcity").focus();
any idea?
maybe calling javascript before input element rendered? position input element before javascript or wait until page loaded before trigger javascript.
in order, works fine:
<input type="text" id="test" /> <script type="text/javascript"> document.getelementbyid("test").focus(); </script>
in jquery place code within .ready()
method execute code first when dom loaded:
<script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#test").focus(); // document.getelementbyid("test").focus(); }); </script>
Comments
Post a Comment