为什么jquery mouseup事件不工作在谷歌浏览器
Why jquery mouseup event is not working in Google Chrome?
我使用这段代码来检测div滚动条上的鼠标up事件。此代码在firefox 3/4/5中运行良好,但在google chrome 12/10/5中不工作。
代码:
jQuery('#slideshow').scroll(function () {
jQuery(this).mouseup(function(){
alert("hi it's a mouse up");
});
});
在firefox中显示警告,但在Google chrome中不显示任何警告。
请告诉我这个问题的解决方法。
-Thanks in advance
这里:演示这与脚本底部的鼠标悬停有冲突。因为mouseover
实际上已经"停止"了画廊。
只是将mouseup
从.scroll() function
中移除,并在where下面添加我们已经有了一个mouseout监听器:
$('#slideshow').bind('mouseover mouseout', function(e) {
if (e.type === 'mouseover') {
clearTimeout(interv);
$('#test').html('Stop on mouseover');
} else {
$('#slideshow').animate({scrollLeft: iw * (counter - 1)}, 1000);
start();
}
});
试试这个:-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Slideshow</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<style type="text/css">
#slideshow
{
width:200px;
padding:10px;
height:200px;
overflow:auto;
}
.slide
{
height:100px;
margin:20px 0px;
background-color:#ccc;
}
</style>
</head>
<body>
<div id="slideshow">
<div class="slide"> </div>
<div class="slide"> </div>
<div class="slide"> </div>
<div class="slide"> </div>
</div>
<script type="text/javascript">
jQuery('#slideshow').scroll(function() {
jQuery(this).mouseup(function() {
alert("hi it's a mouse up");
});
});
</script>
</body>
</html>
我总是建议使用ghomey说的
jQuery(function($){
$('#slideshow').scroll(function(){/*Do something, if need*/}).mouseup(function(){
alert("hi it's a mouse up");
});
}
关于peanut gallery的结果
// Bad
$(window).mouseup(function() { ... });
// Good
window.addEventListener("mouseup", function(event) { ... });
相关文章:
- Javascript字母选择没有'我不能在谷歌浏览器上工作
- 我的时间倒计时脚本在谷歌浏览器中工作正常,但在其他浏览器中打开时它显示为南楠
- 在Firefox上工作的Web工作者在谷歌浏览器上抛出奇怪的错误
- 我的源映射断点在谷歌浏览器中无法正常工作
- 让谷歌浏览器扩展程序只在一个标签上工作
- 谷歌浏览器的“新标签”iframe如何工作
- IE浏览器的Javascript问题,在谷歌浏览器中工作正常,但在IE中则不行
- 是否可以在浏览器中创建类似谷歌浏览器工作区的东西
- Javascript在谷歌浏览器中不能正常工作
- 谷歌浏览器iframe身体加载不工作
- 按钮在谷歌浏览器中不工作
- Javascript的iframes调整功能不工作在谷歌浏览器
- jQuery代码不工作在谷歌浏览器
- POST后禁用按钮在谷歌浏览器不工作
- JavaScript的toggle不工作在谷歌浏览器
- 填写用户名和密码后,当我按下一个回车键无法登录ie,但谷歌浏览器工作正常.如何来
- 无限滚动不工作在谷歌浏览器
- 数组推送功能不工作在谷歌浏览器
- 长字符串在Firefox中自动被截断,而在谷歌浏览器中其工作完美
- 鼠标滚动不工作在谷歌浏览器