2012-04-11 18 views
47

是否可以指示jQuery Mobile不改變我的輸入框和提交按鈕的樣式。我對自定義CSS很滿意。 jQuery手機腳本將自己的風格應用於我的所有元素。如何停止jQuery移動以將樣式應用於我的特定表單元素

我試過的一種解決方法是重寫我的自定義CSS中的那些元素。有什麼其他功能可以在我可以做到這一點?這樣

$.ignoreStyles("button,text"); 

回答

100

jQuery Mobile的一些東西會忽略其data-role屬性被設置爲none元素。因此,您可以簡單地將這些屬性添加到您的標記中:

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

適用於那些需要避免在特定頁面和特定元素上使用jquery移動樣式的例外情況。 – Kon 2014-03-12 22:23:50

+0

數據角色=「無」的提交按鈕是否仍然工作? – utdev 2017-09-04 08:50:49

6

這適用於我。

$(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> 
+0

太棒了,謝謝! – gvsrepins 2014-11-18 20:02:02

2

@angelokh解決方案爲我工作。另外,也要看看下面的鏈接:

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

而且關鍵是包括jquery.mobile.js前添加下面的腳本:

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

給定的鏈接有解決方案,但你的答案在這裏是不完整的...無論如何比x – 2013-08-01 17:44:44

+1

但那麼使用jQuery手機的目的是什麼呢? – yvonnezoe 2014-03-18 03:27:26

-1

試試這個

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