Depending on the element which you have used, you can use the below code:
<script>
function setFocusToTextBox(){
document.getElementById("mytext").focus();
}
</script>
I hope this will help.
Want to become a Java Expert? Join Java Certification now!!
Want to know more about Java? Watch this video on Java Course | Java Tutorial for Beginners: