![](/img/trans.png)
[英]jQuery Mobile: Adding to a SELECT in Code works only on Desktop browsers?
[英]Gravity Forms - jQuery code only works on Desktop and Tablet but not Mobile
我从这个问题中找到了以下代码。
该代码在 Chrome、Firefox 和 Safari 在台式机和平板电脑上运行良好,但在移动设备上不起作用。 我正在尝试使用 Chrome 和 Safari 但没有骰子的 iPhone。 任何想法为什么它不起作用?
jQuery(document).ready(function($) {
$("#input_54_11").change(function() {
var property_state = jQuery(this).val();
if (property_state == 'Georgia') { // get the selected state
jQuery("#input_54_68 option[value='Condominium']").hide();//replace with your value
}else{
jQuery("#input_54_68").children().show()
};
});
});
听起来 jquery 未加载,您可以为此添加测试并添加后备,如下所示:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-3.6.0.min.js"></script>')</script>
你需要交换
js/jquery-3.6.0.min.js
成为您在随附的解决方案源文件中拥有的 jquery 的缩小版本,如果您使用 require 那么
requirejs.config({
enforceDefine: true,
paths: {
jquery: [
'https://code.jquery.com/jquery-3.6.0.min.js',
//If the CDN location fails, load from this location
'js/jquery-3.6.0.min.js'
]
}
});
//Later
require(['jquery'], function ($) {});
另外,尝试添加 CDATA 标签
<script type="text/javascript">
<![CDATA[
// content of your Javascript goes here
]]>
</script>
我锄头这有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.