Javascript DOM onblur Event via HTML Tag onblur attribute

Introduction

This example demonstrates how to assign an "onblur" event to an input element.

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

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="text" onblur="myFunction()">
<p id="demo"></p>
<script>
function myFunction() {// w w w.  ja  v a  2s  . c om
  document.getElementById("demo").innerHTML = "Input field lost focus.";
}
</script>

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












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



PreviousNext

Related