<!DOCTYPE html>
<html lang="en-US">
<body>
<p>Type your Name and Blur the input field</p>
<input type="text">
<script>
var x = document.getElementsByTagName("input")[0];
function myFunction() {
x.style.color = "red";
}
x.addEventListener("focusout", myFunction);
</script> </body>
</html>