Reputation: 39
I got the function taking the input name as a parameter.
function getInputs(inputName) {
return document.querySelectorAll(`input[name=${inputName}[]]`);
}
I want to join it to the brackets but it throws the exception
The input name looks like this
What am I doing wrong?
Upvotes: 0
Views: 77
Reputation: 5379
function getInputs(inputName) {
return document.querySelectorAll(`input[name="${inputName}[]"]`);
}
Surround your attribute selector value with quotes.
Upvotes: 1