输入模式应用程序状态,直到下次使用 Jquery 单击
Enter modal application state until the next click with Jquery
在拖放方面取得了有限的成功,主要是因为慢速移动设备的缓慢和跳跃行为,我想实现一种模态方法,将元素从 a 移动到 b,如下所示:
- 用户单击项目。通过设置 css 类对项目进行视觉标记。
- 用户单击目标项。标记的项目会立即移动到目标项目。
或者:
- 用户单击目标项目以外的任何位置:标记的项目未标记,并且不会发生任何其他操作。
因此,这个想法是在 (1) 中输入模态状态,并将模态状态保留在 (2) 或 (3) 动作中。
我在实现 (1) 和 (2) 时没有问题。我现在不知道的是如何最好地实施(3)。我应该将一般的"其他任何地方"点击绑定到什么?
很久
以前我也遇到了这个问题。所以我想出了这个(黑客?)解决方案。
小提琴
基本上,它使用"代理"div来模拟"除内容以外的任何内容"。
.HTML
<div id="wrapper">
<div id="general_everywhere"></div>
<div class="button">Button here</div>
<div class="button">Button here</div>
<div class="button">Button here</div>
<div class="button">Button here</div>
<div class="button">Button here</div>
<div class="button">Button here</div>
<div class="button">Button here</div>
<div class="button">Button here</div>
<div class="button">Button here</div>
<div class="button">Button here</div>
</div>
.CSS
#general_everywhere
{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
_background: blue;
display: block;
}
.button
{
position: relative;
padding: 10px;
width: 100px;
margin: 5px;
background: #efefef;
}
.clicked
{
background: red;
}
jQuery
$('.button').click(function(){
$(this).toggleClass('clicked');
});
$('#general_everywhere').click(function(){
$('.button').removeClass('clicked');
alert('You clicked on everywhere! You are GOD!');
});
希望对您有所帮助。
相关文章:
- jquery单击隐藏的复选框
- jQuery单击隐藏其父元素
- 水平滚动不适用于jquery单击
- jQuery单击事件在一次之后不会触发
- Jquery单击按钮上没有类或id的事件
- 将JQuery单击事件直接指向同一元素的两个
- 如何通过使用jQuery单击该DIV来获取children DIV类名
- 使用 jQuery 单击链接时更改链接背景颜色
- JQuery:单击范围标签时切换日期选择器
- 如何使用jQuery单击其缩略图时显示主图像
- JQuery单击“选择子图像”
- 使用jQuery单击锚后,更改锚的文本
- jQuery单击并显示元素列表
- JQuery:单击具有特定URL的嵌套Img
- Jquery单击“选中最近的复选框”
- Jquery单击按钮时不显示警告框
- 突出显示iframe内的文本,同时使用jquery单击文档上的相同文本
- 无法识别JQuery单击事件
- jquery单击链接并获取单选输入值以更改span中的文本
- 使用jquery单击事件淡入隐藏文本