<input type=text value='Welcome to plus2net' class='form-control' id=my_input>
<BR><BR>
<input type="button" name="btn" value="Click to Focus text input" onclick="to_focus()";>
<input type="button" name="btn" value="Click to Blur text input" onclick="to_blur()";>
<br><br>
<script language=javascript>
function to_focus(){
document.getElementById("my_input").focus();
}
function to_blur(){
document.getElementById("my_input").blur();
}
</script>
window.focus method can bring focus to the window. Here is the syntax
window.focus();
When window is opened , the focus remains on it.Check the status of the window focus by using document.hasFocus()
You can see the source code of this demo at blur()