簡單的拼接字串方法 新建陣列 然後push()進去內容 最後join(“”)分割
阿新 • • 發佈:2019-02-18
Dom.$plus.one('click',function(){
var $tit = $(this).parent(".computed").siblings(".food_big_con_right_tit").html();
var $single_price = $(this).siblings(".single_price").html();
var result = [];
result.push('<li class="clearfix">');
result.push('<span class="food_name">'+$tit+'</span>');
result.push('<div class="do_list">');
result.push('<span>¥</span>');
result.push('<strong class="last_item_price">'+$single_price);
result.push('</strong>');
result.push('<img src="images/f/minus.png" class="minus">');
result.push('<span class="last_count">'+1);
result.push('</span>')
result.push('<img src="images/f/plus2.png" class="plus_count">');
result.push('</div> </li>');
result=result.join("");
$('.bottom_menu_list ul').append(result);
// 購物車的數量
var len = Dom.$bottom_menu_list.find("ul li").length;
Dom.$car_number.html(len);
});
var $tit = $(this).parent(".computed").siblings(".food_big_con_right_tit").html();
var $single_price = $(this).siblings(".single_price").html();
var result = [];
result.push('<li class="clearfix">');
result.push('<span class="food_name">'+$tit+'</span>');
result.push('<div class="do_list">');
result.push('<span>¥</span>');
result.push('<strong class="last_item_price">'+$single_price);
result.push('</strong>');
result.push('<img src="images/f/minus.png" class="minus">');
result.push('<span class="last_count">'+1);
result.push('</span>')
result.push('<img src="images/f/plus2.png" class="plus_count">');
result.push('</div> </li>');
result=result.join("");
$('.bottom_menu_list ul').append(result);
// 購物車的數量
var len = Dom.$bottom_menu_list.find("ul li").length;
Dom.$car_number.html(len);
});