2013年3月11日星期一

jquery-table management2




$('td').click(function(){
    var colIndex = $(this).parent().children().index($(this));
    var rowIndex = $(this).parent().parent().children().index($(this).parent());
    alert('Row: ' + rowIndex + ', Column: ' + colIndex);
});

Javascript-table management1

to alert the text value of each td
Copy code
  1. $('table tr td').each(function(){
  2.       var texto = $(this).text();
  3. });

if you want the value of the first row second column, otherwise known as row 1 cell 2 or position(1,2), 
Copy code
  1. var texto = $('table tr:nth-child(1) td:nth-child(2)').text()