[英]How can I add an oninput attribute to an element through HTML DOM?
[英]Add oninput attribute to HTML element with Javascript
如何使用 javascript 將 oninput 添加到 html <input>
元素?
newinput.oninput = 'foo();';
這不起作用 - 有沒有辦法做到這一點?
document.getElementById('my_input').addEventListener("input", function () { console.log('input happened;'); });
<input id="my_input">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.