Can jQuery check whether input content has changed?

前端 未结 9 1028
轮回少年
轮回少年 2020-12-23 19:30

Is it possible to bind javascript (jQuery is best) event to \"change\" form input value somehow?

I know about .change() method, but it does not trigger

9条回答
  •  天涯浪人
    2020-12-23 20:11

    You can also store the initial value in a data attribute and test it with the current value.

     
    
    $("#id_someid").keyup(function() {
        return $(this).val() == $(this).data().initial;
    });
    

    Would return true if the initial value has not changed.

提交回复
热议问题