Given an array of attributes like the following:
let elementsArray = [
'[name="country_code"]',
'[name="user_tel_code"]',
'[name="countryCode"]'
];
If I aim to iterate through them using a function called loopFunc
, it would look something like this:
function loopFunc(elementsArray) {
for (target of elementsArray) {
let targetElem = document.querySelector(target);
console.log(targetElem);
}
}
However, instead of obtaining each DOM element, the output shows null.
The issue here lies in trying to incorporate both single and double quotes within the document.querySelector
method simultaneously.