I don't know what its term, it's like when have a non empty HTML input text then while the focus is on before that input's tabindex, you hit the TAB key, then it has a blue selection around the text.
How do you do that with Javascript?
I think you mean "Selection". Look at the javascript DOM functions select() and focus(). e.g.
<input type="text" id="myTextBox" />
<script type="text/javascript">
var myTextBox = document.getElementById('myTextBox');
myTextBox.select();
myTextBox.focus();
</script>