我的页面中有多个jquery脚本。页面和multipe脚本中有两个jquery版本( 1.8和1.10 ),如下所示:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script>
var jv8 = jQuery.noConflict();
jv8(function () {
jv8('#discounted').attr("disabled", true);
});
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
var jv10 = jQuery.noConflict();
jv10(function () {
jv10('#discounted').attr("disabled", true);
});
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
var jv10 = jQuery.noConflict();
jv10(function () {
jv10('#discounted').attr("disabled", true);
});
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
var jv10 = jQuery.noConflict();
jv10(function () {
jv10('#discounted').attr("disabled", true);
});
</script>第一个脚本使用jquery版本1.8,三个脚本使用jquery版本1.10.2
但这不管用。我怎么才能解决这个问题?我应该如何使用noConflict?
发布于 2015-03-31 03:03:16
问题在于脚本标记,您需要显式地关闭它,否则它将跳过所有脚本,直到遇到下一个</script>。
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script>
var jv8 = jQuery.noConflict();
jv8(function ($) {
$('#discounted').prop("disabled", true);
});
</script>演示:柱塞
https://stackoverflow.com/questions/29359788
复制相似问题