如果我们单击页面上的任何位置,气泡应该关闭
Bubble should close if we click any where on the page
$(document).ready(function() {
$('#username_input').live("focus", function() {
$('.user-available-info').hide();
$('.user-available-error').hide();
$('.login-error').hide();
});
$('#password_input').live("focus", function() {
$('.login-error').hide();
$( '#login-username-invalid').hide();
$( '#login-username-error').hide();
});
This is the xhtml page
<h:panelGroup id="login-username-invalid" >
<div id="login-username-invalid-error">
<div class="login-error">
<div class="login-error-top"></div>
<div class="login-error-middle">
<p class="error">
"message to be displayed in the bubble"</P>
我们在应用程序中有一个登录页面,如果用户输入无效的用户名或密码,则会弹出错误气泡。我们有一个要求,如果用户单击页面上的任何位置,气泡应该关闭。它适用于用户名和密码输入字段,因为我给出了上面代码中列出的 .hide。但是我尝试将输入字段 ID 更改为"body",以使其在整个页面上工作。但它从未奏效。我尝试了 .click 和 .bind 它们都不起作用。有没有解决方案 为它。提前谢谢。
绑定到单击正文,而不是焦点:http://jsfiddle.net/brentmn/QDjSV/1/
$('body').on('focus', function(){
alert('body does not recieve focus');
});
$('body').on('click', function(){
alert('body does recieve click');
});
相关文章:
- jquery试图按名称获取按钮位置
- 我可以获得相对于被点击元素的确切点击位置吗
- 谷歌地图固定位置覆盖
- 在单击任何位置时隐藏元素,而不检查每次DOM单击
- 循环比赛位置算法
- es6 相当于下划线查找位置
- jQuery循环在特定位置暂停
- 引导程序:在导航栏中,显示悬停在单个位置的基于Li Link的不同内容
- 自定义函数中的光标位置
- 安卓平台上的QWebView HTML5地理位置
- DIV并排,位置不正确
- 使用jQuery更改元素的顶部位置
- 在谷歌地图上绘制位置数据库
- 跟踪jqplot垂直折线图的鼠标位置
- 设置画布渲染器的x和y位置
- 固定位置菜单时滚动,直到它击中一个相对容器的底部
- 根据页面的位置突出显示文本中的字符
- 如何使气泡图随机位置
- 如果我们单击页面上的任何位置,气泡应该关闭
- 是否可以调整 D3 气泡图以获得分散位置的气泡而不是圆形包