How to set table cell value using jquery

后端 未结 5 873
情书的邮戳
情书的邮戳 2021-02-09 18:30

I would like to set the value of all the cells of a table by iterating through them. Ideally I would like to access a Html table like an array i.e. $(\"#tbl\")[row][col]=\

5条回答
  •  终归单人心
    2021-02-09 18:44

    You mean like this?

    12
    12
    12
    12
    var tr = 1; $('table tr').each(function(){ var td = 1; $(this).find('td').each(function(){ $(this).append(' | TR : ' + tr + ' TD : ' + td ); td++; }); tr++; });

    Live demo here : http://jsfiddle.net/8xFFH/

    Iterates through all the TD's so you know which you're in. You can also just use $('table tr td').append() if it's a static append.

提交回复
热议问题