jQuery <input> handle focus lost event

Description

jQuery <input> handle focus lost event

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Executing a Function on Blur Event in jQuery</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<style>
    label{//from   w  w w  . j  a v  a  2s .  c o  m
        display: block;
        margin: 5px 0;
    }
    label span{
        display: none;
    }
</style>
<script>
$(document).ready(function(){
    $("input").blur(function(){
        $(this).next("span").show().fadeOut("slow");
    });
});
</script>
</head>
<body>
    <form>
        <label>Email: <input type="text"> <span>blur fire</span></label>
        <label>Password: <input type="password"> <span>blur fire</span></label>
        <label><input type="submit" value="Sign In"> <span>blur fire</span></label>
    </form>
    <p>Click away from the form control or press the "Tab" key to remove focus.</p>
</body>
</html>



PreviousNext

Related