如何添加具有不同ID的选择框的相同数量的选择框,即由另一个选择框值选择的选择框?使用其他选择框的值创建其他选择框
如果选择了选项3,应该创建3个新的选择框。 如果选择了选项2,则应创建2个新的选择框。 ... 我希望你明白。
有人可以帮我吗?万分感谢!
<select name="children" id="children">
<option>1</option>
<option>2</option>
<option>3</option>
...
</select>
<div id="add_select">
...and below should be new created with jquery...
<select name="children" id="child-1-age">
<option>1</option>
<option>2</option>
<option>3</option>
...
</select>
<select name="children" id="child-2-age">
<option>1</option>
<option>2</option>
<option>3</option>
...
</select>
</div>
jQuery的克隆是什么ü需要 – bipen
你甚至可以尝试一个循环将循环内构建选择标签直到第一个列表框的计数值为止......这样,您甚至可以考虑在动态创建的列表框中添加唯一的ID' – dreamweiver
设置您的初始选择列表选项的实际'value'属性,然后您可以在for循环中使用该值,并创建其他列表 – tymeJV