所以,我在一个 CMS 中工作,我有自定义代码来选择从计算年龄得出的资金水平。此代码适用于多种形式,并且可以正常工作,除非我无法控制货币级别的值或 id。表格与表格之间的层次结构保持不变,捐赠级别标签容器也是如此,但是随着每次新的迭代,id 和值都会更改为新的 5 位数字。
<div class="donation-levels">
<div class="donation-level-container">
<div class="form-content">
<div class="donation-level-input-container form-input">
<div class="donation-level-label-input-container">
<input type="radio" name="level_installmentexpanded" id="level_installmentexpanded16025"
value="16025"/>
</div>
<label for="level_installmentexpanded16025" onclick="">
<div class="donation-level-amount-container"> $250.00 </div>
<div class="donation-level-label-container"> Age 40 and under </div>
</label>
</div>
<input type="hidden" name="level_installmentexpandedsubmit" id="level_installment_16025expandedsubmit" value="true" />
</div>
</div>
<div class="donation-level-container">
<div class="form-content">
<div class="donation-level-input-container form-input">
<div class="donation-level-label-input-container">
<input type="radio" name="level_installmentexpanded" id="level_installmentexpanded16022"
value="16022"/>
</div>
<label for="level_installmentexpanded16022" onclick="">
<div class="donation-level-amount-container"> $230.00 </div>
<div class="donation-level-label-container"> Age 41-60 </div>
</label>
</div>
<input type="hidden" name="level_installmentexpandedsubmit" id="level_installment_16022expandedsubmit" value="true" />
</div>
</div>
<div class="donation-level-container">
<div class="form-content">
<div class="donation-level-input-container form-input">
<div class="donation-level-label-input-container">
<input type="radio" name="level_installmentexpanded" id="level_installmentexpanded16021"
value="16021"/>
</div>
<label for="level_installmentexpanded16021" onclick="">
<div class="donation-level-amount-container"> $180.00 </div>
<div class="donation-level-label-container"> Age 61-70 </div>
</label>
</div>
<input type="hidden" name="level_installmentexpandedsubmit" id="level_installment_16021expandedsubmit" value="true" />
</div>
</div>
<div class="donation-level-container">
<div class="form-content">
<div class="donation-level-input-container form-input">
<div class="donation-level-label-input-container">
<input type="radio" name="level_installmentexpanded" id="level_installmentexpanded16026"
value="16026"/>
</div>
<label for="level_installmentexpanded16026" onclick="">
<div class="donation-level-amount-container"> $140.00 </div>
<div class="donation-level-label-container"> Age 71-79 </div>
</label>
</div>
<input type="hidden" name="level_installmentexpandedsubmit" id="level_installment_16026expandedsubmit" value="true" />
</div>
</div>
</div>
</div>
使用相对选择器或其他一些巫术,我可以设置一种动态选择它们的方法,而不必在每次将 ID 应用于新表单时都更改它?