js怎么实现购买商品数量的加减效果
1个回答
展开全部
pt type="text/javascript">
function getElementByAttr(tag, attr, value) {
var aElements = document.getElementsByTagName(tag);
var aEle = [];
for (var i = 0; i < aElements.length; i++) {
if (aElements[i].getAttribute(attr) == value)
aEle.push(aElements[i]);
}
return aEle;
}
window.onload = function () {
var box = getElementByAttr("div", "data-box", "buy");
for (var i = 0; i < box.length; i++) {
calculate(box[i]);
}
}
function calculate(box) {
var oBtn = box.getElementsByTagName("button");
var ipt = box.getElementsByTagName("input")[0];
function getElementByAttr(tag, attr, value) {
var aElements = document.getElementsByTagName(tag);
var aEle = [];
for (var i = 0; i < aElements.length; i++) {
if (aElements[i].getAttribute(attr) == value)
aEle.push(aElements[i]);
}
return aEle;
}
window.onload = function () {
var box = getElementByAttr("div", "data-box", "buy");
for (var i = 0; i < box.length; i++) {
calculate(box[i]);
}
}
function calculate(box) {
var oBtn = box.getElementsByTagName("button");
var ipt = box.getElementsByTagName("input")[0];
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询