I am looking for way to select element inside of already located element in variable. For example I have selected a container:
let productAttachedFilesModal = document.getElementById('modal_more_information');
I know, that inside are array of a
elements, which I want to select as well. Which method should I use? in jQuery there are method find()
. So I need the analog for JS.
Or I need to use DOM method again? Like this:
let listOfLinks= document.getElementById('modal_more_information > a');
Advertisement
Answer
There are several ways:
let anchors = productAttachedFilesModal.getElementsByTagName("a"); let anchors = document.querySelectorAll("#modal_more_information > a") let anchors = productAttachedFilesModal.querySelectorAll("a");