Javascript examples for DOM:Document querySelector
Use CSS ">" selector to select particular div using document.querySelector
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from www.ja v a2 s . c om document.querySelector('body > div + div').style.color = 'red'; } </script> </head> <body> <div> Mango </div> <div> Apple </div> <div> Satsuma </div> <div> Watermelon </div> </body> </html>