Javascript DOM onfocusout Event via HTML Tag onfocusout function

Introduction

onfocusout Event via HTML Tag onfocusout function may not work as expected in Chrome, Safari and Opera 15+.

object.onfocusout = function(){
       myScript};

This example uses the HTML DOM to assign an "onfocusout" event to an input element.

Write something in the input field, and then click outside the field to lose focus.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="text" id="fname">
<p id="demo"></p>
<script>
document.getElementById("fname").onfocusout = function() {myFunction()};

function myFunction() {//ww  w.j av a2  s .c  o m
  document.getElementById("demo").innerHTML = "Input field lost focus.";
}
</script>

</body>
</html>
Bubbles:
Cancelable:
Event type:
Supported HTML tags:












Yes
No
FocusEvent
ALL HTML elements,
EXCEPT:
<base>,
<bdo>,
<br>,
<head>,
<html>,
<iframe>,
<meta>,
<param>,
<script>,
<style>, and
<title>



PreviousNext

Related