Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery error?? How to get the first "td" in all rows that are visible

I have a table and I am hiding some rows. I want to get the first td in all of the rows that are showing. I have the following statement

$("table.SimpleTable tbody tr:visible td:first-child");

this works in FireFox but not in IE any ideas?

like image 919
runxc1 Bret Ferrier Avatar asked May 07 '09 21:05

runxc1 Bret Ferrier


1 Answers

I am running the code on a click event. The html that you have written is pretty much spot on but for the some reason unknown to me it is not working. I have found a work around though. (I am trying to get a comma delimited string of all values in the first td for the visible rows) Anyway the following work around gets the job done.

    var notfirst = false;
    var serials = "";
    var tds = $("table.SimpleTable tbody tr:visible td:first-child");
    for (var i = 0; i < tds.length; i++) {
        var td = $(tds[i]);
        if (td.is(":hidden"))
            continue;
        if (notfirst)
            serials += ",";
        else
            notfirst = true;

        serials += $.trim(td.text());
    }

For some reason the :hidden tag works correctly but not the :visible in IE7

like image 172
runxc1 Bret Ferrier Avatar answered Oct 15 '22 15:10

runxc1 Bret Ferrier