使用javascript在表格中添加水平线

时间:2013-05-13 09:22:03

标签: javascript jquery

我想绘制一条水平粗线,用于根据一个列值分隔报表中的行。即,如果先前和当前值相同,我想绘制一条水平线。 为此,我写了jquery编码,它在mozilla中运行良好,但在IE中没有。我犯了什么错误?

var a = 1;
$(".calbody tr td:nth-child(8) a").each(function() {
    var foo = "<hr width=2000% ;'>";
    if (a === 1) {
        $(this).parents("tr:first").before(foo);
    }
    if (a != 1) {
        var b = $(this).text();  
        if (a != b) {
            $(this).parents("tr:first").before(foo);    
        }
    }
    a = $(this).text();  
});

1 个答案:

答案 0 :(得分:0)

试试这个

var foo = "<hr width='2000%'>";