Javascript html5数字字段在值增加或减少时区分事件
我使用HTML5数字字段来设置顶部位置,当数字字段随up[内部数字字段]增加时,我需要增加顶部值,反之亦然,如果是减少,则需要减少顶部值Javascript html5数字字段在值增加或减少时区分事件,javascript,jquery,html,Javascript,Jquery,Html,我使用HTML5数字字段来设置顶部位置,当数字字段随up[内部数字字段]增加时,我需要增加顶部值,反之亦然,如果是减少,则需要减少顶部值 $("#font_y_pos").change(function(event) { var obj = canvas.getActiveObject(); if (!obj) return; var y_pos = obj.getTop() - $(this).val(); obj.set('top', y_pos); canvas.renderA
$("#font_y_pos").change(function(event) {
var obj = canvas.getActiveObject();
if (!obj)
return;
var y_pos = obj.getTop() - $(this).val();
obj.set('top', y_pos);
canvas.renderAll();
});
但我如何区分这两个事件???价值是增加还是减少
// before the first click on the field, store the original value
elm.onfocus=function () {elm.prevValue = elm.value; };
elm.onclick= function () {
// when clicking the field, write to log the diff between current value and previous
console.log ((elm.prevValue - elm.value)>0); // output=true/false depending on your direction
// store current value as previous for next iteration
elm.prevValue = elm.value;
};