Jquery mobile 阻止jquery mobile设置元素的样式

Jquery mobile 阻止jquery mobile设置元素的样式,jquery-mobile,Jquery Mobile,我想在页面上隐藏一个复选框。显然,我的第一次尝试是: <input type='checkbox' style='display:none' /> 但是,我注意到jquery mobile自动将复选框包装在一个div中,如下所示: <div class='ui-checkbox'> <input type='checkbox' style='display:none;' /> </div> 我假设有某种数据-元素会阻止这种额外的样式

我想在页面上隐藏一个复选框。显然,我的第一次尝试是:

<input type='checkbox' style='display:none' />

但是,我注意到jquery mobile自动将复选框包装在一个div中,如下所示:

<div class='ui-checkbox'>
  <input type='checkbox' style='display:none;' />
</div>


我假设有某种
数据-
元素会阻止这种额外的样式,但在文档或其他地方没有找到它。在css中覆盖
.ui复选框
以隐藏它很容易,但更倾向于使用jquery移动标准方法。是否存在这种情况?

阻止样式设置的属性是
数据角色=“无”


请参阅“防止表单元素的自动初始化”以了解未来用户

如果您想禁用每个表单元素,或者您的表单在无法编辑标记的情况下动态加载,请使用此选项

        $(document).on('pagebeforecreate', function( e ) {
            $( "input, textarea, select", e.target ).attr( "data-role", "none" );
        });

我的位置太多,无法更改输入和添加数据role=“无” 以下代码适用于我:

 <script>
        $(document).bind('mobileinit',function(){
            $.mobile.page.prototype.options.keepNative = "select,input";
        });        
    </script>
    <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>

$(document).bind('mobileinit',function(){
$.mobile.page.prototype.options.keepNative=“选择,输入”;
});        

对于未来的用户,从jQuery版本1.7Nice and easy开始,该函数已被弃用,取而代之的是该函数。。在2015年仍然是一个有效的解决方案,当前版本(1.4.5)。
 <script>
        $(document).bind('mobileinit',function(){
            $.mobile.page.prototype.options.keepNative = "select,input";
        });        
    </script>
    <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>