jquery:当内容发生改变时触发事件
(当元素的值改变时发生 change 事件(仅适用于表单字段)。
change() 方法触发 change 事件,或规定当发生 change 事件时运行的函数。
注意:当用于 select 元素时,change 事件会在选择某个选项时发生。当用于 text field 或 text area 时,change 事件会在元素失去焦点时发生)
<span class="buynum" contentEditable="true">1</span>
$(".buynum").bind("input propertychange",function(){
// 先得到span文本框的里面的值 乘以 当前商品的单价
var n = $(this).text();
// 当前商品的单价
var p = $(this).parents(".number").siblings(".drug_price").html();
// console.log(p);
p = p.substr(1);
$(this).parents(".number").siblings(".sAll").html("¥" + (p * n).toFixed(2));
getSum();
});