- editValue中,第二个参数必填value。即代表自动获取input 框实时的value值
<input type="text" value='{$vo.now_oil|default=""}' onBlur="editValue('{$vo.id}',value)" onFocus="showValue('{$vo.id}','{$vo.now_oil}')">
<script>
let now_id = 0;
let now_value = 0;
function showValue(id,value) {
now_id = id;
now_value = value;
}
function editValue(id,value) {
if (id == now_id && value == now_value){
console.log('未发生改变,id=',now_id,'value=',value,'now_value=',now_value);
return false;
}
$.post(
"/admin/equipment_parameter/editCarNowOil",
{
id: id,
value: value
},
function (res) {
if (!res.code){
layer.alert(res.msg, {icon: res.code,});
}else {
layer.msg('设置成功');
}
}
);
}
</script>
网友评论