jQuery Mobile:使用 tap 绑定 if 语句
jQuery Mobile: Binding if statement with tap
>首先是小提琴
有三个div,HTML代码:
<div class="container" data-role="page" id="container">
<div class="popup">
<div class="close">
</div><!-- /.close -->
</div><!-- /.popup -->
</div><!-- /.container -->
.container - 是一个大背景,它包含页面。
.popup - 是容器内的div。
.close - 是".popup"div 中的一个小白色div
这就是我想要的 - 当点击页面上的任何位置时,整个div .container 必须隐藏,除了弹出窗口,当点击弹出窗口时,它应该保持原样。
现在只满足一个条件,如果点击发生在任何地方,整个div .container都会消失,现在1. 如何防止div .container 在点击 .popupdiv 时消失。
j查询代码:
$(document).on("pagecreate","#container",function(){
$(".container").on("tap",function(){
$(".container").hide();
});
});
你可以试试:
$('.popup').siblings().hide();
或
$('.container').children().not('.popup').hide();
它将隐藏与div.popup
具有相同父级的元素。
您可以查看返回
的 tap 事件j查询代码:
$(document).on("pagecreate","#container",function(){
$(".container").on("tap",function(tapEvent){
if (!$(tapEvent.target).hasClass("popup")){
$(".container").hide();
}
});
});
相关文章:
- 如何在数据绑定视图中模板化If Else结构
- KnockoutJS:无法处理绑定"if:function(){return conversations}”;
- KnockoutJS:将if绑定封装在自定义绑定中
- 挖空.js使用 $index 和 if 绑定
- jQuery Mobile:使用 tap 绑定 if 语句
- 在 Foreach 循环中使用 IF 条件来比较数据绑定值
- KnockoutJS “if: ” 绑定无法正常工作
- Knockout Js 的渲染方式与基于 Json 值的 if 数据绑定不同
- 在 if 语句中淘汰奇怪的绑定问题
- Knockoutjs:如何在不使用if的情况下过滤foreach绑定
- 使用ko.mapping插件时,IF绑定未按预期工作
- knockout.js:If和foreach绑定,检查可观察数组上的真值
- 带有if绑定的$index不起作用
- Angularjs动态ng-if数据绑定在span中
- Angular JS中ng-if表达式中条件单向绑定的语法
- 剔除条件绑定(但不是本机的“if”方式)
- 可以在Knockout中创建自定义if绑定
- 我可以在Knockoutjs中的if绑定中访问jquery调用中的$data吗?
- 此模板引擎不支持'if'在其模板内绑定
- 自定义指令在ng-if中第二次绑定不正确