Javascript examples for DOM HTML Element:Style
Get second child using CSS via document.querySelector
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*w ww. j av a 2 s . co m*/ var secondChild = document.querySelector('.parent > td:nth-of-type(2)'); console.log(secondChild); // <td>element two</td> } </script> </head> <body> <table> <tbody> <tr class="parent"> <td>element one</td> <td>element two</td> </tr> </tbody> </table> </body> </html>