1
<script src="jquery.mobile/jquery.easing.1.3"></script>
<script src="jquery.mobile/jquery.mobile.scrollview"></script>
<script src="jquery.mobile/scrollview"></script>
....! and the correct css !
身体:
<div data-role="page" data-theme="a" id="mainpage">
<div data-role="content" data-theme="a">
<div id="htmltext" data-scroll="y"></div>
</div><!-- /content -->
</div>
在Pageshow事件:
$("#htmltext").load("content/test.htm", function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
alert(msg + xhr.status + " " + xhr.statusText);
}
});
$("#htmltext").scrollview("scrollTo", 0, -600);
load()之后,不能滚动动态div #htmltext !!!
同时,如果我用纯代码替换加载函数,它将正确滚动。
我错过了什么吗?
我尝试过使用您的代码,但它不工作。将事件绑定到#htmltext也不起作用。 我已经使用了CSS函数,比如'code'transform(),transform3d(),...但它们裁剪内容,不滚动内容。 – TonyWu
@TonyWu代码可行。检查你的'scrollview'函数。它存在吗?我知道'.scrollTop()'方法,不能说这个。 – VisioN
它理论上看起来很有作用,但实际上它不起作用。 加载后没有事件触发事件: 'Link //加载故事内容。 $('#htmltext')。load(“test.htm”,function(response,status,xhr){if(status ==“error”){ var msg =“对不起,但出现错误:” ; console.error(msg + xhr.status +“”+ xhr.statusText); } $('#ctrl')。trigger('click'); }); ('#ctrl')。bind('click',function(event){ console.log(“ctrl.click”); $('#htmltext')。scrollview(“scrollTo”,0, -600); });' scrollview()属于jquery.mobile.scrollview.js – TonyWu