ドキュメント

Events/blur

From jQuery JavaScript Library

Jump to: navigation, search

« Back to Events

blur( )

Triggers the blur event of each matched element.
This causes all of the functions that have been bound to that blur event to be executed, and calls the browser's default blur action on the matching element(s). This default action can be prevented by returning false from one of the functions bound to the blur event. The blur event usually fires when an element loses focus either via the pointing device or by tabbing navigation
Examples:

To triggers the blur event on all paragraphs:

$("p").blur();

NameType

blur( fn )

Bind a function to the blur event of each matched element.
The blur event fires when an element loses focus either via the pointing device or by tabbing navigation.
Arguments:
fnFunction
A function to bind to the blur event on each of the matched elements.
function callback(eventObject) {
  this; // dom element
}
Examples:

Fire blur.

    $("input").blur(function () {
         $(this).next("span").css('display','inline').fadeOut(1000);
    });

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    
    $("input").blur(function () {
         $(this).next("span").css('display','inline').fadeOut(1000);
    });

  });
  </script>
  <style>span {display:none;}</style>
</head>
<body>
  <p><input type="text" /> <span>blur fire</span></p>
<p><input type="password" /> <span>blur fire</span></p>
</body>
</html>

NameType