[英]javascript: How to clean an input box when another input value changed?
我根據另一個輸入(#parent)提出了一個輸入(#child)自動建議。 #parent輸入值更改后,我想清除#child的值。 我想學習如何做,謝謝!
您可以訂閱父項的onchange
事件,然后清除子項的值:
window.onload = function() {
// the document has loaded => we could access the DOM
// we subscribe to the onchange event pf the parent:
document.getElementById('parentId').onchange = function() {
// and when this event is triggered we clean the child
// element value
document.getElementById('childId').value = '';
};
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.