/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: onblur

[this page | pdf | back links]

The HTML onblur attribute specifies the event that is triggered when an element loses focus. It applies to all visible elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
onblur: enter text in this input field and try leaving it
<input type="text" onblur="myOnblur()"><br>

<script>
function myOnblur() {alert("Moving out of input element");}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile