JQuery: Get original input value

前端 未结 7 1945
面向向阳花
面向向阳花 2021-02-07 01:51

Is it possible to get the initial value of a form input field?

For example:

7条回答
  •  说谎
    说谎 (楼主)
    2021-02-07 02:37

    var initialVal = $('#one').val();
    alert(initialVal);
    $('#one').live("focusout", function() {
        var attribute = $("#one").attr("value");
        var value = $(this).val();
        var get = $(this).get(0).value;
        alert( "Attribute: " + attribute + "\n\nValue: " + value + "\n\ninit val: " + initialVal +"\n\nGet: " + get );
    });
    

提交回复
热议问题