var $page = el.parents('div[data-role="page"]:visible');
在 pageinit()
上调用对我来说显示为 null。有谁知道从 JQM 访问元素高度的适当处理程序? (因为我需要在显示元素时运行 height())
谢谢。
最佳答案
如果您想要在 jQuery Mobile 中引用当前显示的页面,可以使用 $.mobile.activePage
属性(property)。它存储当前页面的 jQuery 对象。
所以要得到当前<div data-role="page">
的高度你会做的元素:
var the_height = $.mobile.activePage.height();
或者您可以获得 <div data-role="content">
的高度部分:
var the_height = $.mobile.activePage.children('[data-role="content"]').height();
这是文档中关于此的页面的链接(但是几乎没有关于此属性的信息,您可能仍想浏览该页面以查看 jQuery Mobile 内置的内容):http://jquerymobile.com/demos/1.0rc2/docs/api/methods.html
关于html - jquerymobile pageinit() 页面隐藏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8089917/