blur() loses focus and focus() gets focus event in jquery

黄舟
Release: 2017-06-26 14:08:26
Original
4707 people have browsed it

In the past, when we wrote various input events in js, we would write them directly in the input. Yesterday, I started to fully use jquery. Now let’s talk about my study notes on the jquery blur() focus() event.

For the focus event of the element, we can use jQuery's focusfunctionfocus(), blur().

focus(): Used when focus is obtained, the same asonfocusinjavascript.

Such as:

$("p").focus(); 或$("p").focus(fn)
Copy after login

Such as: blur(): used when the focus is lost, the same as onblur.

$("p").blur(); 或$("p").blur(fn)
Copy after login

Example

 
Enter your name:

请在上面的输入域中点击,使其获得焦点,然后在输入域外面点击,使其失去焦点。

Copy after login

When the mouse is clicked in the search box, the text inside disappears.

   input失去焦点和获得焦点jquery焦点事件插件   

input失去焦点和获得焦点jquery焦点事件插件,
鼠标在搜索框中点击的时候里面的文字就消失了

Copy after login

An ajax value to determine whether to show or hide p

 * 手机:  用房乐网会员登录名可获取5房乐币   js $(function(){ $('#tgmo').blur(function(){ $.post('post.php?action=check',{'tgmo':$('tgmo').val()},function(data) { if( data==0 ) { $('#sy_a').show(); $('#autoregister').val(1); } else { $('#sy_a').hide(); $('#autoregister').val(0); } }); }) });
Copy after login


The above is the detailed content of blur() loses focus and focus() gets focus event in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!