字符串累加不成功,请教哪里出问题了,谢谢
小弟不太懂JS,代码是从网上找的,参考了#contentArea,给#mylist 赋值,希望得到累加的字符串,结果运行后得到的是最后一组字符串,前面的字符串没有累加进来...哪里错了,请教大神 contentListInit: function () {
var betStorage = $.fn.check.getLocalBetArray();
var zscount = 0;
var countamount = 0;
var c = 0, lx = 1;
$("#contentArea").empty();
$("#mylist").empty();
if (betStorage.length > 0) {
$(".nullNotice").hide();
$.each(betStorage, function (index) {
var html = "";
var hlist = ""; //声明hlist
var guid = betStorage[index].Guid;
var betType = betStorage[index].BetType.toLowerCase();
var betContent = betStorage[index].Content;
var typename = $.fn.check.playWays[betType].name;
var betcount = betStorage[index].BetCount;
var type = $.fn.check.playWays[betType].play;
if (type.indexOf('dt') < 0) {//
if (-1 != betContent.indexOf('#')) {
typename = typename + "dt";
}
}
if ('l3' == type || 'l2' == type || -1 != type.indexOf('l4') || -1 != type.indexOf('l5')) {
c = 2;
if ('l2' == type || 'l3' == type) {
lx = 1;
} else if (-1 != type.indexOf('l4')) {
lx = 1;
} else {
lx = 1;
}
var betAmount = (betcount / lx) * $.fn.check.getSigMoney(type);
} else {
var betAmount = betcount * $.fn.check.getSigMoney(type);
}
var minPrice = $.fn.check.calculate(betContent, type, betcount);
html += '<li data-type="' + betType + '" id="' + guid + '" data-price=' + minPrice + ' class="tab">';
html += '<div class="tab-cell ver-middle" style="width:2.5rem;"><span class="delete_c" attr-id="' + guid + '">X</span></div>';
html += '<lable style="display:none" name="zs">' + betcount + '</lable><span style="display:none" class="red" name="je">' + betAmount + '</span>';
html += '<div class="tab-cell ver-middle"><p name="betct" class="wrap"><span class="red" name="redball">' + betContent + '</span></p>';
html += '<span class="color-999999" data-pt="' + type + '">' + typename + '</span> <span class="color-999999">' + betcount + '</span> <span class="color-999999">' + betAmount + '</span></div>';
html += '<div class="tab-cell ver-middle upNumPar" data-pt="' + type + '" data-id="' + guid + '" data-cont=' + betContent + '><i class="upNumBtn"></i><div>';
html += '</li>';
$("#contentArea").append(html);
zscount = zscount + betcount * 1;
countamount = countamount + betAmount * 1;
hlist += betContent + betType + betcount + betAmoun +countamount; //累加
$("#mylist").val(hlist); //显示
$.fn.check.origMoney = countamount;
})
} else {
$(".nullNotice").show();
}
//改变最大倍数
if (!c) {
$.fn.check.maxBs = MaxBetMultiple;
} else {
$.fn.check.maxBs = 99;
}
$(".zhu1,#autoBetCounts").text(Number(zscount));
var qs = $("#issue").val();
var bs = $("#multiple").val();
var amount = Number(countamount) * Number(qs) * Number(bs);
$(".money").text(amount);
$("#betCount").val(zscount);
$("#countAmount").val(amount);
$("#bs").val(bs);
$("#qs").val(qs);
$("#mymoney").val(amount);
init();
},
[此贴子已经被作者于2017-6-25 17:10编辑过]