Basic JavaScript Question:
Download Questions PDF

How to set the 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 JavaScript Interview Questions And Answers PDF

Previous QuestionNext Question
How to determine the state of a checkbox using JavaScript?How to access an external JavaScript file that is stored externally and not embedded?