【发布时间】:2015-09-28 11:40:57
【问题描述】:
我有两个 DropDownLists 开始隐藏:
$(window).load(function () {
. . . other code elided for brevity
$('[id$=ddlPayToIndividual]').hide();
$('[id$=ddlPayToVendor]').hide();
});
...但是根据单击的相应单选按钮显示一个:
$(document).on("click", '[id$=rbPaymentToIndividual]', function () {
if (this.checked) {
$('[id$=ddlPayToVendor]').slideUp();
$('[id$=ddlPayToIndividual]').slideDown();
}
});
$(document).on("click", '[id$=rbPaymentToVendor]', function () {
if (this.checked) {
$('[id$=ddlPayToIndividual]').slideUp();
$('[id$=ddlPayToVendor]').slideDown();
}
});
当用户单击单选按钮(rbPaymentToIndividual 或 rbPaymentToVendor)时,这一切都有效;但是,当我以编程方式检查它时:
$(document).on("click", '[id$=rbPaymentForSelf]', function () {
if (this.checked) {
. . . other code elided for brevity
$('[id$=rbPaymentToIndividual]').attr('checked', true);
}
});
...它没有。为什么?是否有一种变通方法可以让它认为程序化的属性操作等同于用户的直接参与?
【问题讨论】:
标签: jquery radio-button html-select attr checked