@
swordne function gelegate(action, selector, callback) {
var event = event || window.event;
if (document.addEventListener) {
document.addEventListener(action, function (event) {
if (selector === event.target.tagName.toLowerCase() || selector === event.target.className || selector ===
event.target.id) {
callback();
}
}, false);
} else if (document.attachEvent) {
document.attachEvent('on' + action, function (event) {
if (selector === event.srcElement.tagName.toLowerCase() || selector === event.srcElement.className || selector ===
event.srcElement.id) {
callback();
}
});
} else {
selector['on' + action] = callback();
}
}
gelegate('click', 'li', function () {
var $inputVal = $(this).prev('input'),
$count = parseInt($inputVal.val()) + 1,
$obj = $(this).parents('.amount_box').find('.reduce'),
$priceTotalObj = $(this).parents('.order_lists').find('.sum_price'),
$price = $(this).parents('.order_lists').find('.price').html(), //单价
$priceTotal = $count * parseInt($price.substring(1));
$inputVal.val($count);
$priceTotalObj.html('¥' + $priceTotal);
if ($inputVal.val() > 1 && $obj.hasClass('reSty')) {
$obj.removeClass('reSty');
}
//totalMoney();
});
我这样写的 但是貌似没触发
<li class="list_amount">
<div class="amount_box margin-top-bar">
<a href="javascript:;" class="reduce reSty">-</a>
<input type="text" value="1" class="sum">
<a href="javascript:;" class="plus">+</a>
</div>
</li>