gpt4 book ai didi

javascript - 括号中缺少 )

转载 作者:搜寻专家 更新时间:2023-11-01 05:25:55 25 4
gpt4 key购买 nike

我不断收到我的 javascript missing ) 在括号中
[出现此错误时中断] if ( (this.scrollTop < this.scrollH...uches[0].pageY > scrollStartPosY+5) )

function touchScroll(id){
if(isTouchDevice()){ //if touch events exist...
var el=document.getElementById(id);
var scrollStartPosY=0;
var scrollStartPosX=0;

document.getElementById(id).addEventListener("touchstart", function(event) {
scrollStartPosY=this.scrollTop+event.touches[0].pageY;
scrollStartPosX=this.scrollLeft+event.touches[0].pageX;
//event.preventDefault(); // Keep this remarked so you can click on buttons and links in the div
},false);

document.getElementById(id).addEventListener("touchmove", function(event) {
// These if statements allow the full page to scroll (not just the div) if they are
// at the top of the div scroll or the bottom of the div scroll
// The -5 and +5 below are in case they are trying to scroll the page sideways
// but their finger moves a few pixels down or up. The event.preventDefault() function
// will not be called in that case so that the whole page can scroll.
if ( (this.scrollTop < this.scrollHeight-this.offsetHeight) && (this.scrollTop+event.touches[0].pageY < scrollStartPosY-5) || (this.scrollTop != 0 && this.scrollTop+event.touches[0].pageY > scrollStartPosY+5) )
event.preventDefault();
if ((this.scrollLeft < this.scrollWidth-this.offsetWidth && this.scrollLeft+event.touches[0].pageX < scrollStartPosX-5) || (this.scrollLeft != 0 && this.scrollLeft+event.touches[0].pageX > scrollStartPosX+5))
event.preventDefault();
this.scrollTop=scrollStartPosY-event.touches[0].pageY;
this.scrollLeft=scrollStartPosX-event.touches[0].pageX;
},false);
}
}

我一辈子也想不通这是为什么。

最佳答案

尝试 JS Lint .它非常适合在脚本中查找不明显的语法错误。

关于javascript - 括号中缺少 ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7122430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com