JavaScript/jQuery 实时监听 input 输入框值变化



jQuery 代码:

$("#input1").bind("input propertychange",function(event){
   console.log($("#input1").val());
});


JavaScript 代码:

// Firefox, Google Chrome, Opera, Safari, InternetExplorer 9+
    function oninput (event) {
        alert ("The new content: " + event.target.value);
    }
// InternetExplorer8-
    function onpropchanged (event) {
        if (event.propertyName.toLowerCase () == "value") {
            alert ("The new content: " + event.srcElement.value);
        }
    }

你可能感兴趣的:(JavaScript/jQuery 实时监听 input 输入框值变化)