jquery-mobile - 使用节、页眉和页脚标签而不是数据角色

标签 jquery-mobile

Jon Reid 在他的 jQuery Mobile 书中有一个使用 html5 标签的好主意:

<section data-role="page">
<header data-role="header">
<nav data-role="navbar">
<div data-role="content">
<footer data-role="footer">

问:如果我使用节、页眉和页脚标签,是否可以去掉 data-role="page","header","nav","footer"?
也许我可以在 jQuery Mobile 加载之前加入一些 js 优点。

理论上,如果我在加载 jQuery Mobile 之前添加它,它将起作用:
$('header').attr('data-role','header');

嗯...虽然我可能需要在应用此属性后刷新元素。
或者触发一个创建方法。

最佳答案

我在 jQuery Mobile JavaScript 之前这样做:

$('section').attr('data-role','page');
$('article').attr('data-role','content');
$('header').attr('data-role','header');
$('nav').attr('data-role','navbar');
$('aside').addClass('ui-li-aside');
$('ul').not('nav > ul').not('.nolst').attr('data-role','listview').attr('data-inset','true');
$('ol').not('nav > ol').attr('data-role','listview').attr('data-inset','true');;
$('a').not('li > a').not('.nobtn').attr('data-role','button');
$('footer').attr('data-role','footer');

关于jquery-mobile - 使用节、页眉和页脚标签而不是数据角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9165323/

相关文章:

javascript - Phonegap 与 jquery 移动 "hello world"不工作

html - 数据位置固定在 BlackBerry 中使用 jquery mobile 不起作用

android - 在HTML5移动应用上播放全屏视频,出现黑屏并崩溃的应用

javascript - 在 HTML5 上取消滚动

jquery - 具有动态内容的固定表头?

jQuery 移动元素未在 div 中居中对齐

javascript - $.mobile.showPageLoadingMsg 不是函数

jquery-mobile - 如何在页面转换期间禁用工具栏按钮?

javascript - jquery mobile Pageshow - 删除以前的数据

android - 关于使用 jQuery Mobile 和 html 开发 android 应用程序