动态显示/添加
我有这样的代码:
<table id="SomeTable">
<tr>
<td>Rows:</td>
<td><select name="Rows" id="Rows">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></td>
</tr>
<tr>
<td>#1</td>
<td><input type="text"></td>
</tr>
......
<tr>
<td>#5</td>
<td><input type="text"></td>
</tr></table>
是否可以以某种方式动态显示下拉列表中选择的行数?并使用 JQuery 在第一行或每行添加当前数字?
哪种方式最好解决这个问题?是否可以在删除/添加这些 tr 时为其设置动画?
/米
I have this code:
<table id="SomeTable">
<tr>
<td>Rows:</td>
<td><select name="Rows" id="Rows">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></td>
</tr>
<tr>
<td>#1</td>
<td><input type="text"></td>
</tr>
......
<tr>
<td>#5</td>
<td><input type="text"></td>
</tr></table>
Is it possible to somehow dynamically show the number of rows selected in the droplist? And add the current number in the first or each row using JQuery?
Which way is the best to solve this? And is it possible to animate those tr's as they are removed/added?
/M
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
:gt()
选择器,如下所示:它是一个基于 0 的索引,但由于下拉列表本身在顶部有一个额外的行,因此效果很完美。另一个稍微干净的替代方案是
.slice()
,如下所示:动画,你可以做一些淡入淡出,但是在 IE 中对表行进行动画处理尤其令人讨厌,我会远离它。
You can use the
:gt()
selector, like this:It's a 0-based index, but since you have an extra row up top with the drop down itself, this works out perfect. Another slightly cleaner alternative is
.slice()
, like this:For the animating, you could do some fading, but animating table rows in particular is nasty in IE, I'd stay away from it.
我不确定你的意思,你是否试图根据选择框的值添加 n 个元素?
I'm not sure what you mean, are you trying to add n numbers of element based on the select box's value?