1

我创建了一个自定义控件,它具有多种类型的控件,例如单选按钮列表、下拉列表、文本框等。我正在使用控件状态来保存值。我正在使用 jQuery 重置自定义控件中所有控件的值,但新值不会传输到控件。

我正在调用以下函数来重置自定义控件中的控件,但是当我在单击按钮时保存内容时,控件的值没有得到更新。

function ResetControls() {
    $('div[id$=test]').each(function () {
        $(this).find('table').each(function () {
            if ($(this).attr("id").indexOf("_ph_Test1") > 0) {
                $(this).find('tr').each(function () {
                    $(this).find('input[type=radio]').each(function () {
                        $(this).removeAttr('checked');
                        $(this).change();
                    });
                    $(this).find('textarea').each(function () {
                        $(this).val('');
                        $(this).change();
                    });
                    $(this).find('select').each(function () {
                        $(this).val('');
                        $(this).change();
                    });
                    if (!$(this).is(':first-child')) {
                        $(this).hide();
                    }
                });
            }
        });
    });
}

我们如何使用 javascript 或 jQuery 更新控件的控件状态?

4

0 回答 0