Event handler onblur
(Bubbles: No, Cancelable: No) terjadi ketika suatu elemen kehilangan fokus -- menjadi tidak aktif.
Berikut contoh meregister event handler onblur
via 'inline model':
<FORM>
Tulis nama Anda:
<INPUT TYPE="text" ONBLUR="this.style.background='red'">
</FORM>
Berikut contoh meregister event handler onblur
via 'traditional model':
<FORM>
Tulis nama Anda:
<INPUT TYPE="text" ID="inputTextID">
</FORM>
<SCRIPT TYPE="text/javascript">
function HandleEvent()
{
this.style.background="red";
}
var inputElem=document.getElementById("inputTextID");
inputElem.onblur=HandleEvent;
</SCRIPT>
Berikut contoh meregister event handler onblur
via DOM:
<FORM>
Tulis nama Anda:
<INPUT TYPE="text" ID="inputTextID">
</FORM>
<SCRIPT TYPE="text/javascript">
function HandleEvent()
{
this.style.background="red";
}
var inputElem=document.getElementById("inputTextID");
inputElem.addEventListener("blur", HandleEvent, false);
</SCRIPT>