我想将 Jquery 移动 CSS 和 JS 仅应用于某些有限的元素,而不应用于页面上的其他元素。知道我该怎么做吗?
我有一些 Salesforce 标准客户门户,其中包含一个包含 Jquery、mobile 和 CSS 的选项卡。
现在,当我在 Customer Portal 中打开选项卡时,它会覆盖 Salesforce 标准样式。
Thanks
取决于您使用的 jQuery Mobile 版本。
-
解决方案一:
-
Modify 全局设置 on mobileinit
, 通过设置ignoreContentEnabled
to true。但是,这会对应用程序性能产生负面影响,因为它会减慢处理/初始化小部件/元素的速度。
<head>
<script src="jQuery.js"></script>
<script>
$(document).on("mobileinit", function () {
$.mobile.ignoreContentEnabled = true;
});
</script>
<script src="jQuery-Mobile.js"></script>
<head>
-
Add data-enhance="false"
到您想要保持 jQM 不受影响的元素或 div。
<div data-role="content" data-enhance="false">
<!-- elements -->
</div>
<input type="text" data-enhance="false">
-
解决方案2:
-
Modify page小部件默认打开mobileinit
,通过设置.选择器 for keepNative
. The .选择器可能是一个<tag>
, an #id
or a .class
.
-
jQuery 移动
<head>
<script src="jQuery.js"></script>
<script>
$(document).on("mobileinit", function () {
$.mobile.page.prototype.options.keepNative = $.mobile.page.prototype.options.keepNative + ", input, #foo, .native";
});
</script>
<script src="jQuery-Mobile.js"></script>
<head>
-
jQuery 移动 >= 1.4.x
<head>
<script src="jQuery.js"></script>
<script>
$(document).on("mobileinit", function () {
$.mobile.keepNative = $.mobile.keepNative + ", input, #foo, .native";
});
</script>
<script src="jQuery-Mobile.js"></script>
<head>
创建页面时,input
, 元素与#foo
ID 和元素native
类,将保持原样。
Demo
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)