code is like this
<div class="linkPillar"> <a href="github"><img src="github.png" alt="GitHub"></a> <a href="facebook"><img src="fb.png" alt="facebook"></a> </div>
and i want to select all a’s just inside of linkPillar without giving each of them an id. is there any way to make this, thanks
Advertisement
Answer
You can use the query selector to find the elements:
console.log(document.querySelectorAll('.linkPillar a'));
<div class="linkPillar"> <a href="github"><img src="github.png" alt="GitHub"></a> <a href="facebook"><img src="fb.png" alt="facebook"></a> </div>