DEV Community


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’>
 </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 (0)

Editor guide