2
I’m looking to change some attributes within the fields: ul > li. In case I change the.url and img.src, however I am using a for to change the fields is using in the mode artistSimimarChild[i] how can I access ul > li > a and ul > li > a > img ?
HTML:
<ul class="ui-artist-related">
<li class="ui-artist-related__column ui-artist-related__artist"><a href="#"><img src="assets/images/profiles/katyperry.jpg" /></a></li>
<li class="ui-artist-related__column ui-artist-related__artist"><a href="#"><img src="assets/images/profiles/kesha.jpg" /></a></li>
<li class="ui-artist-related__column ui-artist-related__artist"><a href="#"><img src="assets/images/profiles/arianagrande.jpg" /></a></li>
</ul>
Javascript:
const artistSimilar = document.querySelector(".ui-artist-related"),
artistSimimarChild = document.querySelectorAll("li.ui-artist-related__artist");
The closest way I thought would be to do:
var 1 = document.querySelectorAll("li.ui-artist-related__artist > a")[i];
var 2 = document.querySelectorAll("li.ui-artist-related__artist > a > img")[i];
However I do not want to keep creating several var to select a specific field and in the end get a mess my code.