data-fullscreen="true"
当我为标题设置属性时,它工作正常。但是当我收到一些事件时,我确实需要在运行时执行此操作。我试过这个:
$(document).ready(function() {
$("[data-role=header]").attr("data-fullscreen", "true");
});
在 Chrome 的元素检查中,属性data-fullscreen
更改为true
,但标题没有任何反应。有谁知道另一种方式?
data-fullscreen="true"
当我为标题设置属性时,它工作正常。但是当我收到一些事件时,我确实需要在运行时执行此操作。我试过这个:
$(document).ready(function() {
$("[data-role=header]").attr("data-fullscreen", "true");
});
在 Chrome 的元素检查中,属性data-fullscreen
更改为true
,但标题没有任何反应。有谁知道另一种方式?
这是一个工作示例:http: //jsfiddle.net/Gajotres/HCcUe/
和代码示例:
$(document).on('pagebeforeshow', '#index', function(){
$('[data-role="header"]').attr({'data-fullscreen':'true','data-position':'fixed'}).html('<h3>Test</h3>');
$('#index').trigger('pagecreate');
});
使用 pageshow 或 pagebeforeshow 页面事件来设置此属性。也不要使用 jQuery Mobile 准备好的文档,在这里你会发现原因:https ://stackoverflow.com/a/14469041/1848600