There are several layered elements in a div with a product class. These include two images. The first image is the product thumbnail, and the second image is the product rating. They both have no class, and I cannot change the html code. Sometimes images are wrapped inside the <a></a> tag.
I need to select only image product . This is the first img that appears in order inside each div.product .
<html> <style> img { border: solid 2px black } </style> </head> <body> <div class="product"> <a href="#"><img border="0" src="http://www.vistaview360.com/cameras/images/nikon_images/nikon-d5500-s.jpg" alt="Nikon D5500" width="140" height="140" data-pin-nopin="true"></a><br> <img src ="http://www.vistaview360.com/menuimages/stars-5.jpg"/> </div> <div class="product"> <a href="#"><img border="0" src="http://www.vistaview360.com/cameras/images/nikon_images/nikon-d5500-s.jpg" alt="Nikon D5500" width="140" height="140" data-pin-nopin="true"></a><br> <a href="#"><img src ="http://www.vistaview360.com/menuimages/stars-5.jpg"/></a> </div> <div class="product"> <img border="0" src="http://www.vistaview360.com/cameras/images/nikon_images/nikon-d5500-s.jpg" alt="Nikon D5500" width="140" height="140" data-pin-nopin="true"><br> <a hre="#"><img src ="http://www.vistaview360.com/menuimages/stars-5.jpg"/></a> </div> <div class="product"> <img border="0" src="http://www.vistaview360.com/cameras/images/nikon_images/nikon-d5500-s.jpg" alt="Nikon D5500" width="140" height="140" data-pin-nopin="true"><br> <img src ="http://www.vistaview360.com/menuimages/stars-5.jpg"></img> </div> </body> </html>
I tried with first-of-type and first-child , but this method ignores children and children. Wrapped image is ignored. How can I do this without changing the html code ?
source share