Javascript jquery 1.6.2消失1.9.1函数,反之亦然
我面临着这个问题,只是通过切换其中一个来完成我的工作 实际上,我的基本模板已经在jquery 1.6.2中进行了编码,现在我正在使用基于1.9.1库的其他jquery函数,函数如下:Javascript jquery 1.6.2消失1.9.1函数,反之亦然,javascript,jquery,Javascript,Jquery,我面临着这个问题,只是通过切换其中一个来完成我的工作 实际上,我的基本模板已经在jquery 1.6.2中进行了编码,现在我正在使用基于1.9.1库的其他jquery函数,函数如下: <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <SCRIPT language="javascript"> $(function () { $(":c
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<SCRIPT language="javascript">
$(function () {
$(":checkbox").change(function () {
// Toggle class of selected row
$(this).parent().toggleClass("rowSelected");
// Get all items name, sum total amount
var sum = 1500;
var arr = $(":checkbox:checked").map(function () {
sum += Number($(this).parents('tr').find('td:last').text());
return $(this).parents('tr').clone();
}).get();
// Display selected items and their sum
$("#selectedServices").html(arr).find('input').remove();
$("#total").text(sum);
});
});
</script>
$(函数(){
$(“:复选框”).change(函数(){
//切换所选行的类
$(this.parent().toggleClass(“rowSelected”);
//获取所有项目的名称、总和和总金额
var总和=1500;
var arr=$(“:复选框:选中”).map(函数(){
sum+=Number($(this).parents('tr').find('td:last').text());
返回$(this.parents('tr').clone();
}).get();
//显示所选项目及其总和
$(“#selectedServices”).html(arr.find('input').remove();
$(“#总计”)。正文(总和);
});
});
现在,由于1.6.2不支持该函数,当我使用1.9.1和1.6.2时
<head>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
只有1.6.2支持的功能正常工作,在删除1.6.2时,控制台显示错误,1.9.1支持的功能(如上所述)正常工作
我想让它们支持的所有功能一起工作。怎么做?您的最佳选择是只使用jquery 1.9.1(或更新版本)
然后,要更新所有脚本/函数,请使用jquery migrate,这将让您知道要在代码中更改什么:1.6.2不支持哪个函数?您的代码在两个版本中都可以运行。@未定义检查此选项,您将得到以下答案:fiddle似乎工作正常,我在控制台中没有看到任何错误。我们在寻找什么问题?版本1.9.1支持的fiddle中的代码,但我的模板在删除时已在1.6.2中编码。6.2此代码(在fiddle中)运行良好,但其他许多代码正在破坏模板,运行不正常。我希望同时使用1.6.2和1.9.1