Expert JavaScript Developer Question:
Download Questions PDF

How to set focus in an element using Javascript?

Answer:

Setting the focus in an element using JavaScript:

<script>
function setFocus() {
if(focusElement != null)
{
document.forms[0].elements["myelementname"].focus();
}
}
</script>

Download Expert JavaScript Developer Interview Questions And Answers PDF

Previous QuestionNext Question
How to get contents of an input box using JavaScript?How you can access an external JavaScript file that is stored externally and not embedded?