3 回答
TA贡献1830条经验 获得超3个赞
onchange
"onkeydown"
"onpaste"
("oninput"
(
1<textarea>
textInput
TA贡献1995条经验 获得超2个赞
oninput
.onchange
onpropertychange
const $source = document.querySelector('#source');
const $result = document.querySelector('#result');
const typeHandler = function(e) {
$result.innerHTML = e.target.value;
}
$source.addEventListener('input', typeHandler) // register for oninput
$source.addEventListener('propertychange', typeHandler) // for IE8
// $source.addEventListener('change', typeHandler) // fallback for Firefox for <select><option>, for <input> oninput is enough
<input id="source" />
<div id="result"></div>
TA贡献1793条经验 获得超6个赞
<input type="text" id="myId" />
$("#myId").on('change keydown paste input', function(){ doSomething();});
添加回答
举报