我有一个页面操作,使用类似于:
$('#thetable tbody').replaceWith(newtbody);
Run Code Online (Sandbox Code Playgroud)
在ajax回调中.有时,如果用户向下滚动页面,则此操作具有向上滚动页面的可理解的副作用.但是替换对用户来说似乎是无缝的,因此再次向下滚动有点烦人.并且由于newtbody通常具有与其替换的垂直高度相同的垂直高度,因此我们应该能够使脚本代替它.
现在,因为我发现执行:
$('body').scrollTop(300);
Run Code Online (Sandbox Code Playgroud)
从JS调试器控制台做我希望它会做的,我认为简单的补救措施是:
var scrollsave = $('body').scrollTop();
$('#thetable tbody').replaceWith(newtbody);
$('body').scrollTop(scrollsave);
Run Code Online (Sandbox Code Playgroud)
但没有快乐.我还没有使用jQuery.ScrollTo.
在浏览器中按后退按钮时,是否可以将用户带回到他们向下滚动的页面区域?因为--- pageA是你的屏幕尺寸的两倍(因此你必须滚动阅读更多).单击pageA上的链接转到新页面 - pageB.阅读后,单击浏览器中的.现在,当您返回到pageA时,您将返回到顶部,并且必须向下滚动到您继续阅读页面其余部分的位置.
是否有Jquery或JS方法返回到页面中的那一点.也许是.scrollTop()的东西?
我正在使用JavaScript移动元素,我需要为拖放期间发生的组合创建逻辑
我正在尝试从元素中获取详细信息,像选择器这样的CSS也可以,但是如果可能的话,则不建议使用..(例如chrome开发工具中的复制选择器)
document.onmouseup = function(e){
targetDest = e.target;
//console.log('targetDest: ', targetDest);
let
indexA = Array.from(targetCurr.parentNode.children).indexOf(targetCurr),
indexB = Array.from(targetDest.parentNode.children).indexOf(targetDest);
console.log(indexA, indexB);
if(targetDest != targetCurr){
if(targetDest == document.documentElement){
console.log('document');
}
else if(targetDest == undefined){
console.log('undefined');
}
else if(!targetDest){
console.log('!dest');
}
else if(targetDest == null){
console.log('null');
}
else if(targetDest == false){
console.log('false');
}
else{
console.log('else');
//targetCurr.parentNode.insertBefore(targetDest, targetCurr);
//console.log('...');
}
}else{
console.log('itself');
}
}
Run Code Online (Sandbox Code Playgroud)