1 回答

TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個(gè)贊
課程以句號(hào).classPreviousValuenot開頭classPreviousValue。并嘗試切換on('focusin'到each循環(huán)遍歷所有這些,而無(wú)需用戶交互。同樣在if語(yǔ)句的末尾,將 data-val 更改為新值。
$(".classPreviousValue").each(function() {
$(this).data('val', $(this).val());
});
$(".classPreviousValue").on('change', function() {
var $prev = $(this).data('val');
var $current = $(this).val();
if ($prev !== $current) {
alert ("Things changed");
$(this).css("color", $currentDayColor);
$("#divChangeLog").html($("#divChangeLog").html() + "<br>Value changed from " + $prev);
$(this).data('val',$current); //set data-val to new value
};
});
添加回答
舉報(bào)