// JavaScript Document $(function(){ var trs = $("tr").length; alert(trs); for(var m = 2 ; m < trs ; m++){ var red_one_num = Number($("tr:eq("+m+") td:eq(1)").text()); var red_two_num = Number($("tr:eq("+m+") td:eq(2)").text()); var red_three_num =Number($("tr:eq("+m+") td:eq(3)").text()); var red_four_num = Number($("tr:eq("+m+") td:eq(4)").text()); var red_five_num = Number($("tr:eq("+m+") td:eq(5)").text()); var red_six_num = Number($("tr:eq("+m+") td:eq(6)").text()); var blue_num = Number($("tr:eq("+m+") td:eq(7)").text()); var red_one_txt = $("tr:eq("+m+") td:eq(1)").text(); var red_two_txt = $("tr:eq("+m+") td:eq(2)").text(); var red_three_txt = $("tr:eq("+m+") td:eq(3)").text(); var red_four_txt = $("tr:eq("+m+") td:eq(4)").text(); var red_five_txt = $("tr:eq("+m+") td:eq(5)").text() var red_six_txt = $("tr:eq("+m+") td:eq(6)").text(); var blue_txt = $("tr:eq("+m+") td:eq(7)").text(); //第一组胆:计算red_one+blue的值, var dan_one_num = red_one_num + blue_num; if((dan_one_num)>33){ var dan_one_num = (dan_one_num)-33; } var dan_one_a = dan_one_num + 1; var dan_one_b = dan_one_num - 1; //第二组胆: 红三位拆分的和+蓝球拆分的和 var red_three_a = Number(red_three_txt.charAt(0));//0 var red_three_b = Number(red_three_txt.charAt(1));//8 var blue_a = Number(blue_txt.charAt(0)); var blue_b = Number(blue_txt.charAt(1)); var dan_two_num = red_three_a + red_three_b + blue_a + blue_b; var dan_two_a = dan_two_num + 1; var dan_two_b = dan_two_num - 1; //第三组胆:红二位+蓝球 var dan_three_num = red_one_num + blue_num; if((dan_three_num)>33){ var dan_three_num = (dan_three_num)-33; } var dan_three_a = dan_three_num + 1; var dan_three_b = dan_three_num - 1; //第四组胆:红六位-红四位+1 var dan_four_num = red_six_num - red_four_num + 1; if((dan_four_num)>33){ var dan_four_num = (dan_four_num)-33; } var dan_four_a = dan_four_num + 1; var dan_four_b = dan_four_num - 1; //第五组胆:红六位-红五位+2 var dan_five_num = red_six_num - red_five_num + 2; if((dan_five_num)>33){ var dan_five_num = (dan_five_num)-33; } var dan_five_a = dan_five_num + 1; var dan_five_b = dan_five_num - 1; //第六位:红二位+红三位 var dan_six_num = red_two_num + red_three_num ; if((dan_six_num)>33){ var dan_six_num = (dan_six_num)-33; } var dan_six_a = dan_six_num + 1; var dan_six_b = dan_six_num - 1; //第七组胆:尾和+1 var wei_one = Number(red_one_txt.charAt(1)); var wei_two = Number(red_two_txt.charAt(1)); var wei_three = Number(red_three_txt.charAt(1)); var wei_four = Number(red_four_txt.charAt(1)); var wei_five = Number(red_five_txt.charAt(1)); var wei_six = Number(red_six_txt.charAt(1)); var dan_seven_num = wei_one + wei_two + wei_three + wei_four + wei_five + wei_six; if((dan_seven_num)>33){ var dan_seven_num = (dan_seven_num)-33; } var dan_seven_a = dan_seven_num + 1; var dan_seven_b = dan_seven_num - 1; //第八组胆:(红一位+红六位)/2,取整 var dan_eight_num = parseInt((red_one_num + red_six_num)/2); var dan_eight_a = dan_eight_num + 1; var dan_eight_b = dan_eight_num - 1; //第九组胆:33-(红一位+红二位) var dan_nine_num = Math.abs(33 - (red_one_num + red_two_num)); var dan_nine_a = dan_nine_num + 1; var dan_nine_b = dan_nine_num - 1; //去除重复 Array.prototype.distinct=function(){ var sameObj=function(a,b){ var tag = true; if(!a||!b)return false; for(var x in a){ if(!b[x]) return false; if(typeof(a[x])==='object'){ tag=sameObj(a[x],b[x]); }else{ if(a[x]!==b[x]) return false; } } return tag; } var newArr=[],obj={}; for(var i=0,len=this.length;i<len;i++){ if(!sameObj(obj[typeof(this[i])+this[i]],this[i])){ newArr.push(this[i]); obj[typeof(this[i])+this[i]]=this[i]; } } return newArr; } //排序 function compare(value1, value2) { if (value1 < value2) { return -1; } else if (value1 > value2) { return 1; } else { return 0; } } $(function(){ var dan = new Array(dan_one_num,dan_one_a,dan_one_b, dan_two_num,dan_two_a,dan_two_b, dan_three_num,dan_three_a,dan_three_b, dan_four_num,dan_four_a,dan_four_b, dan_five_num,dan_five_a,dan_five_b, dan_six_num,dan_six_a,dan_six_b, dan_seven_num,dan_seven_a,dan_seven_b, dan_eight_num,dan_eight_a,dan_eight_b, dan_nine_num,dan_nine_a,dan_nine_b); dan.sort(compare); var newdan = dan.distinct(); alert(newdan); for(var i=0,k=8;i<newdan.length,k<8+newdan.length;i++,k++){ //alert(dan[i]); for(var j=3;j<trs;j++){ $("tr:eq("+j+") td:eq("+k+")").html(newdan[i]); } } }); } }); //请你帮我看看这个代码!我的本意是:一行一行的区数据,一行一行的计算,但是现在变成了所有的数据一起计算了