// selecting 3rd list item of 2nd container let element = document.querySelector("#output>.container:nth-child(2) ul li:nth-child(3)"); element.style.background = "lightgreen";