隐藏函数似乎不能在jQuery Mobile中工作
Hide function doesn't seem to be working in jQuery Mobile
我有一个使用jQuery mobile创建的小型移动应用程序。重点是,我有一个div,有3个按钮,还有其他一些东西。如果用户正在工作的设备是Windows(意思是WP),我希望该div上的三个按钮被隐藏。它们的定义如下:
<div id="finalPage" data-role="page" data-add-back-btn="false">
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1>Result</h1>
</div>
<div data-role="content">
<button id="fbPost">Facebook</button>
<button id="twitterPost">Twitter</button>
<button id="g+Post">Google+</button>
</div>
</div>
在JS端,我有这样的代码:
document.addEventListener("deviceready", WPshare, false);
function WPshare() {
if (navigator.userAgent.indexOf('Windows') > -1) {
console.log("The device is Windows Phone!");
$("#fbPost").hide();
$("#twitterPost").hide();
$("#g+Post").hide();
}
}
关键是它似乎不起作用。当用户打开带有id"finalPage"的页面时,我希望这三个按钮被隐藏(不可见,不可点击)。还请注意,在WP设备上执行console.log行。只有按钮没有被隐藏。有什么办法吗?
试试这个:
现场演示
JQuery if($('#finalPage').length != 0){
console.log('final is found');
$("#fbPost").closest('div').hide();
console.log($("#fbPost"));
}
相关文章:
- 无法从jquery Mobile导航栏重定向到另一个页面
- jquery mobile上多个页面上的一个表单
- window.location使用jquery mobile实现chrome跳转
- 防止jQuery Mobile中的ajax缓存
- 如何在JQUERY Mobile上放置谷歌地图
- JQuery Mobile Javascript复杂方程式
- jQuery Mobile Undefined不是一个函数
- jQuery mobile not going through ID
- 如何使用javascript或jquery mobile从url读取和显示XML文件
- jQuery Mobile Collapse上的AJAX请求
- 应用程序在呈现Jquery Mobile之前显示无样式的Html
- 如何在jQuery Mobile 1.4 Datepicker中创建事件
- UIWebview赢得't通过基本身份验证加载动态加载的资源(通过jQuery mobile)
- jQuery Mobile到其他页面的锚链接不起作用
- 如何在jQuery Mobile中设置100%宽度的输入类型日期
- JQuery Mobile破坏了我的布局:如何禁用自动打字
- 防止用户在jQuery Mobile中ajax加载页面时单击其他位置
- 根据手机上是否存在文件,在jQuery mobile中动态填充列表视图
- Image Sprites和jQuery Mobile Ajax导航的问题
- jQuery Mobile:如何在$.Mobile.changePage之前运行回调函数