focus

UK[ˈfəʊkəs] US[ˈfoʊkəs]

vt.& vi. (to make) focus, (to make) gather; adjust (lens, eyes) ) focus [focal length] in order to see clearly

vt. adjust the focal length (of the eye or lens); focus (the beam on); focus, gaze; concentrate

n. focus; image clarity; center (of activity, attention, interest, etc.); [medicine] focus, disease

jquery focus() method syntax

Function:When an element gains focus, the focus event occurs.

Trigger focus event syntax: $(selector).focus()

##Bind the function to the focus event syntax: $ (selector).focus(function)

Parameters:

##Parametersfunction

jquery focus() method 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>
Run instance »

Click the "Run instance" button to view the online instance

About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!

Description
Optional. Specifies the function to be run when the focus event occurs.​