1

1 つの入力 (#child) の自動提案を別の入力 (#parent) に基づいて作成しました。#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 に答える