1

我根据另一个输入(#parent)提出了一个输入(#child)自动建议。当#parent 输入值改变时,我想清理#child 的值。我想学习如何做到这一点,谢谢!

4

1 回答 1

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 = '';
    };
};
于 2012-07-15T10:17:25.150 回答