<script type="text/javascript">
var rowin=1;
var arrcount=[0,0,0];
var arrprice=[100.0,200.5,120.0];
function deltr(obj) {
var table = document.getElementById("first");
table.deleteRow(obj);
}
$(".Madd").click(function(){
if(arrcount[0]<=0){
var table = document.getElementById("first");
var row = table.insertRow(rowin++);
row.setAttribute("align", "center");
var td1 = row.insertCell(0);
td1.innerHTML = $(this).parent().parent().find("td:eq(1)").text();
console.log($(this));
var td2 = row.insertCell(1);
td2.innerHTML = '<button class="add">+</button><a class="mcount" id="mcount">1</a><button class="min">-</button>';
td2.setAttribute("id","add");
var td3 = row.insertCell(2);
td3.innerHTML = '<span id="mprice">0</span>';
arrcount[0]++;
$("#mprice").text(arrprice[0]);
$("#all").text(arrcount[0]*arrprice[0]);
}else{
arrcount[0]++;
$(".mcount").text(arrcount[0]);
$("#mprice").text(arrcount[0]*arrprice[0]);
$("#all").text(arrcount[0] * arrprice[0]);
}
})
$(".add").click(function() {
console.log(this);
arrcount[0]++;
$(".mcount").text(arrcount[0]);
$("#mprice").text(arrcount[0] * arrprice[0]);
$("#all").text(arrcount[0] * arrprice[0]);
})
$(".min").click(function() {
console.log(this);
arrcount[0]--;
$(".mcount").text(arrcount[0]);
$("#mprice").text(arrcount[0] * arrprice[0]);
$("#all").text(arrcount[0] * arrprice[0]);
})
这个add绑定的按钮为什么没反应?jquery引入正常的,js代码也是写在body后面的,加载顺序也是在文档读完后