admin管理员组文章数量:1389779
I would like to add a horizontal seperating line on a dynamic populated table. How do I do this? Below is a snippet.
function addNewRow() {
$('#displayTable tr:last').after('<tr><td style="font-size:smaller;" class="dataField1"></td><td style="font-size:smaller;" class="dataField2"></td><td style="font-size:smaller;" class="dataField3"></td></tr>');
var $tr = $('#displayTable tr:last');
$tr.find('.dataField1').text($('#txtName').val());
$tr.find('.dataField2').text($('#txtAddress').val());
$tr.find('.dataField3').text('document.write("<tr><td colspan=\"2\"><hr \/><\/td><\/tr>");
}
I would like to add a horizontal seperating line on a dynamic populated table. How do I do this? Below is a snippet.
function addNewRow() {
$('#displayTable tr:last').after('<tr><td style="font-size:smaller;" class="dataField1"></td><td style="font-size:smaller;" class="dataField2"></td><td style="font-size:smaller;" class="dataField3"></td></tr>');
var $tr = $('#displayTable tr:last');
$tr.find('.dataField1').text($('#txtName').val());
$tr.find('.dataField2').text($('#txtAddress').val());
$tr.find('.dataField3').text('document.write("<tr><td colspan=\"2\"><hr \/><\/td><\/tr>");
}
Share
Improve this question
edited Jun 16, 2010 at 13:50
MrM
asked Jun 16, 2010 at 13:45
MrMMrM
22.1k31 gold badges116 silver badges142 bronze badges
4
- Why is this tagged c# and java? – jjnguy Commented Jun 16, 2010 at 13:47
- @jjnguy - Sorry about that :) – MrM Commented Jun 16, 2010 at 13:51
- @user No worries, it is just helpful for everyone if you use the right tags. I wasn't sure if you had a Java or C# ponent to your question. – jjnguy Commented Jun 16, 2010 at 13:58
-
What type of element is
dataField3
? – user113716 Commented Jun 16, 2010 at 14:15
2 Answers
Reset to default 3I would get rid of document.write. Instead of the
<hr>
you are using, put a "css class" that makes the table have a visible bottom border (line will be of course only as wide as the table itself). Something like
border-bottom: 1px solid black;
Prevent document.write
at all times, like everywhere unless you know exactly what you're doing.
Evil thing. Give this a shot:
$('#displayTable tr:last').after('<tr><td style="font-size:smaller;" class="dataField1"></td><td style="font-size:smaller;" class="dataField2"></td><td style="font-size:smaller;" class="dataField3"></td></tr>');
var $tr = $('#displayTable tr:last');
$tr.find('.dataField1').text($('#txtName').val());
$tr.find('.dataField2').text($('#txtAddress').val());
$tr.find('.dataField3').append("<tr><td colspan=\"2\"><hr/><\/td><\/tr>");
本文标签: jqueryHow to Add Horizontal line in JavascriptStack Overflow
版权声明:本文标题:jquery - How to Add Horizontal line in Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744604451a2615268.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论