我在另一个输入(#parent)上做了一个输入(#child)自动建议。当#parent输入值改变时,我想清除#child的值。我想学习如何做到这一点,谢谢!
答案 0 :(得分:0)
您可以订阅父级的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 = '';
};
};