DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,673 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
ishwar chandra tiwari
ishwar chandra tiwari

Posted on

how to get the contents of a table row

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

});

Top comments (0)

In defense of the modern web

I expect I'll annoy everyone with this post: the anti-JavaScript crusaders, justly aghast at how much of the stuff we slather onto modern websites; the people arguing the web is a broken platform for interactive applications anyway and we should start over;

React users; the old guard with their artisanal JS and hand authored HTML; and Tom MacWright, someone I've admired from afar since I first became aware of his work on Mapbox many years ago. But I guess that's the price of having opinions.