Expert JavaScript Developer Question: Download Expert JavaScript Developer PDF

How to set focus in an element using Javascript?

Tweet Share WhatsApp

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 PDF Read All 58 Expert JavaScript Developer Questions
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?