1
我在另一個輸入(#parent)上做了一個輸入(#child)自動建議。當#parent輸入值改變時,我想清除#子值。我想學習如何做到這一點,謝謝!javascript:如何在另一個輸入值更改時清除輸入框?
我在另一個輸入(#parent)上做了一個輸入(#child)自動建議。當#parent輸入值改變時,我想清除#子值。我想學習如何做到這一點,謝謝!javascript:如何在另一個輸入值更改時清除輸入框?
你可以訂閱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 = '';
};
};
謝謝,它的工作原理! – Jenny 2012-07-15 11:01:30