【发布时间】:2014-11-20 01:09:44
【问题描述】:
我有一个带有导航箭头的滑块,当双击箭头时,#slider1 后面的div 即.content-wrapper 被选中,如下所示:
http://gyazo.com/e66ab776b60455d8b496b46e3077099a
如果箭头得到单击,没关系,正常工作,但双击会做出这个奇怪的选择。我怎样才能阻止这种情况?
我已经尝试过这里建议的 stackoverflow 方法,例如:
$('.arrow').dblclick(function(){
return false;
});
和
$('.arrow').dblclick(function(event){
event.preventDefault();
});
它没有用。
这里是html结构:
<div class="content-wrapper">
<h2>Some long enough title</h2>
<div class="red-divider" style="margin-bottom: 50px"></div>
<div class="items">
<div class="arrow left-small"></div>
<div id="slider1">
<ul>
<li>
<div class="item">
<img src="img/item1.png" height="59" width="72" alt="">
<p>Some product description text goes right here</p>
</div>
</li>
<li>
<div class="item">
<img src="img/item1.png" height="59" width="72" alt="">
<p>Some product description text goes right here</p>
</div>
</li>
<li>
<div class="item">
<img src="img/item1.png" height="59" width="72" alt="">
<p>Some product description text goes right here</p>
</div>
</li>
</ul>
</div>
<div class="arrow right-small"></div>
</div>
</div>
箭头显然是.arrow left-small 和.arrow right-small。
请告诉我是否应该在此处发布所有 jQuery 代码和 CSS 样式。
谢谢。
编辑:
这是所有元素的 CSS:
.content-wrapper {
width: 1080px;
height: 100%;
margin: 0 auto;
padding: 0 28px;
position: relative;
}
.items {
margin: 0 auto;
}
#slider1 {
overflow: hidden;
margin: 0 auto;
}
#slider1 ul {
position: relative;
height: 124px;
margin: 0;
padding: 0;
list-style: none;
}
#slider1 ul li {
width: 320px;
position: relative;
display: block;
float: left;
margin: 0;
padding: 0;
}
.item {
display: inline-block;
width: 300px;
vertical-align: top;
background-color: #fff;
border-radius: 5px;
padding: 30px 10px;
}
.arrow {
position: absolute;
top: 55%;
width: 27px;
height: 51px;
display: inline-block;
margin-top: 35px;
cursor: pointer;
z-index: 100;
}
.left-small设置背景图片和left:
EDIT2:
这也是小提琴http://jsfiddle.net/55pewvb9/
EDIT3:
这是完整的页面 space-masters.com/samsung/
【问题讨论】:
标签: jquery html selection double-click