抱歉,當(dāng)用戶選擇第一個下拉菜單時,有沒有辦法將所有下拉菜單重置并清除到原始狀態(tài)。希望我能清楚地解釋自己。先感謝您。HTML <div class="form-group row"> <div class="col-sm-6"> <div id="#divAreYouGoingOnVacation"> <label asp-for="AreYouGoingOnVacation">Are You Going On Vacation</label> <select asp-for="AreYouGoingOnVacation" class="form-control" id="AreYouGoingOnVacation" required> <option value="" selected>-- Please choose an option --</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </div> </div> <div class="col-sm-6"> <div id="divWouldYouBeTakingASpouse"> <label asp-for="WouldYouBeTakingASpouse">Would You Be Taking A Spouse?</label> <select asp-for="WouldYouBeTakingASpouse" class="form-control" id="WouldYouBeTakingASpouse" required> <option value="" selected>-- Please choose an option --</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> <br /><br /> </div> </div>查詢 $("#AreYouGoingOnVacation").change(function () { if ($(this).val() == "Yes") { $("#divWouldYouBeTakingASpouse").show(); } else { $("#divWouldYouBeTakingASpouse").hide(); } }); $("#WouldYouBeTakingASpouse").change(function () { if ($(this).val() == "Yes") { $("#divHowLongAreYouWillingToWaitForFood").show(); } else { $("#divHowLongAreYouWillingToWaitForFood").hide(); } });});
使用 jQuery 從第一個下拉列表中重置和清除
HUWWW
2023-03-18 17:26:01