jQuery - 如何检查文本框是否具有焦点或是否在其中单击鼠标? [英] jQuery - How can I check whether or not a textbox has focus or has a mouse click inside it?

查看:578
本文介绍了jQuery - 如何检查文本框是否具有焦点或是否在其中单击鼠标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我正在尝试检测文本框是否具有焦点或鼠标单击。这就是我现在所拥有的。



  if ($(   textbox)。是( :focus))
{
$(#div).fadeOut( 2000 );
}





目前我没有看到任何变化也没有出现任何错误。有人能告诉我我做错了什么或如何最好地检测文本框的鼠标点击?

解决方案

textbox)。is( :focus ))
{


(#div).fadeOut( 2000 );
}





目前我没有看到任何变化也没有出现任何错误。有人可以告诉我我做错了什么或如何最好地检测文本框的鼠标点击?


你应该处理事件焦点



演示 - [演示]检测TextBox焦点 [< a href =http://jsfiddle.net/taditdash/H8Z7r/target =_ blanktitle =New Window> ^ ]

 

Hi everyone!

I am trying to detect whether or not a textbox has focus or has a mouse click. This is what I have right now.

if($("textbox").is(":focus"))
{
     $(#div).fadeOut(2000);
}



Currently I'm not seeing any changes nor getting any errors. Can someone show me what I'm doing wrong or how to best detect mouse clicks for textboxes?

解决方案

("textbox").is(":focus")) {


(#div).fadeOut(2000); }



Currently I'm not seeing any changes nor getting any errors. Can someone show me what I'm doing wrong or how to best detect mouse clicks for textboxes?


You should handle the Event focus.

Demo - [Demo] Detect TextBox Focus[^]


这篇关于jQuery - 如何检查文本框是否具有焦点或是否在其中单击鼠标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆