这是我的jsp片段,它使用spring mvc
<form:select path="noOfBankDetails" id = "noOfBankDetails">
<form:option value="0">0</form:option>
<form:option value="1">1</form:option>
<form:option value="2">2</form:option>
<form:option value="3">3</form:option>
<form:option value="4">4</form:option>
</form:select>
<!-- All the following divs are hidden -->
<div id = "firstBankDetail">
<div id = "secondBankDetail">
<div id = "thirdBankDetail">
<div id = "fourthBankDetail">
这是我的 jQuery 片段,它显示了下拉 noOfBankDetails 更改时的所有 div
$("#noOfBankDetails").change(function(){
$("#firstBankDetail").show();
$("#secondBankDetail").show();
$("#thirdBankDetail").show();
$("#fourthBankDetail").show();
});
它工作得很好......但我想实现一些不同的东西它的伪像这样
IF noOfBankDetails IS 0 THEN
Show none of divs
ELSE IF noOfBankDetails IS 1 THEN
Show div firstBankDetail
ELSE IF noOfBankDetails IS 2 THEN
Show div firstBankDetail
Show div secondBankDetail
and so on..
我应该如何在 jQuery 中执行此操作。我是 jQuery 的初学者。请提供一些指导。