blur
英[blɜ:(r)] 美[blɚ]
n. stain, stain; vague thing; ambiguous
vt.& vi. Smear, stain; (make) blurred, (make) difficult to distinguish
jquery blur() function syntax
Function:The blur event occurs when the element loses focus. The blur() function triggers the blur event, or if the function parameter is set, the function can also specify the code to be executed when the blur event occurs. Earlier, the blur event only occurred on form elements. In new browsers, this event can be used on any element.
Trigger the blur event: Trigger the blur event of the selected element.
Syntax: $(selector).blur()
Bind the function to the blur eventObject: Requirement Function that runs when the blur event of the selected element occurs.
Syntax: $(selector).blur(function)
Parameters:
Parameters | Description |
function | Optional. Specifies the function to run when the blur event occurs. |
jquery blur() function example
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("input").focus(function(){ $("input").css("background-color","#FFFFCC"); }); $("input").blur(function(){ $("input").css("background-color","#D6D6FF"); }); }); </script> </head> <body> Enter your name: <input type="text" /> <p>请在上面的输入域中点击,使其获得焦点,然后在输入域外面点击,使其失去焦点。</p> </body> </html>
Click the "Run instance" button to view the online instance