CSS 我如何停止 jQuery Mobile 将样式应用到我的特定表单元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10108578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 03:34:39  来源:igfitidea点击:

How can i stop jQuery mobile to apply styles to my specific form elements

cssjquery-mobile

提问by Happy

Is it possible to instruct jQuery Mobile to not style my Input box and submit button. I am good with my custom CSS. jQuery mobile script is applying its own style to all my elements.

是否可以指示 jQuery Mobile 不设置我的输入框和提交按钮的样式。我很擅长我的自定义 CSS。jQuery 移动脚本将其自己的样式应用于我的所有元素。

the one workaround i tried is overriding those elements in my custom css. Is there any other functions available where i can do this ? some thing like this

我尝试的一种解决方法是在我的自定义 css 中覆盖这些元素。是否还有其他功能可用?像这样的事情

$.ignoreStyles("button,text");

回答by Frédéric Hamidi

jQuery Mobile will ignore elements whose data-roleattributes are set to none. Therefore, you can simply add these attributes to your markup:

jQuery Mobile 将忽略data-role属性设置为 的元素none。因此,您可以简单地将这些属性添加到您的标记中:

<input type="text" name="foo" data-role="none" />
<button type="button" id="bar" data-role="none">Button</button>

回答by angelokh

This works for me.

这对我有用。

$(document).bind("mobileinit", function() {
  $.mobile.ignoreContentEnabled = true;
});

<div data-enhance="false">
    <input type="checkbox" name="chkbox1" id="chkbox1" 
      checked />
    <label for="chkbox1">Checkbox</label>
    <input type="radio" name="radiobtn1" id="radiobtn1" 
      checked />
    <label for="radiobtn1">Radio Button</label>
  </div>

回答by user1459013

@angelokh solution worked for me. Also look at the following link:

@angelokh 解决方案对我有用。另请查看以下链接:

http://my.safaribooksonline.com/book/-/9781849517225/7dot-configurations/ch07s06_html

http://my.safaribooksonline.com/book/-/9781849517225/7dot-configurations/ch07s06_html

Also the key is to add the following script before including jquery.mobile.js:

另外关键是在包含 jquery.mobile.js 之前添加以下脚本:

$(document).bind("mobileinit", function() {
  $.mobile.ignoreContentEnabled = true;
});

回答by ViSu Khilari

try this

尝试这个

$(document).on('pagebeforecreate', function( e ) {
    $.mobile.ignoreContentEnabled=true;
});