jquery .html() output ALL elements rather then 1

Deathbywar

New Member
Im trying to output all first tds in all table rows, but .html() only outputs the first, rather then all. From the jquery website:\[quote\] Description: Get the HTML contents of the first element in the set of matched elements.\[/quote\]Relevant code:\[code\]$("button").click(function() { var table1 = '<table><tr>'; var data = http://stackoverflow.com/questions/13870754/$("#myTable tr:first-child").html(); var table2 = '</tr></table>'; var output = table1 + data + table2; $(".result").html(output);});\[/code\]When I change it to:\[code\]$("#myTable:first-child").html();\[/code\]All matching elements are output, all trs, instead of just the first.How can i output all first tds? And what does this rule of "only first matched element" mean? It seems only to apply sometimes...http://jsfiddle.net/vaVe9/
 
Back
Top