loading...

how to get the contents of a table row

ishwar profile image ishwar chandra tiwari ・1 min read

snippet to get tr DATA value

snippet to get td value

html +=
 ` <tr data-id=’JavaScript’>
 <td>1</td>
 <td>2</td>
 <td>3</td>
 <td>4</td>
 <td>5</td>
 </tr> `
 document.getElementById(‘tablebody’).innerHTML = html;

‘#example’).find(‘tr’).click(function() {

console.log(‘===========’, $(this).attr(“data-id”)); // get tr data value
console.log(‘===========’, $(this).data(‘id’));
console.log(‘===========’, $(this).find(‘td:eq(1)’).text()) // get 1st td value

});

Discussion

pic
Editor guide