I am trying to check for activity on any of some specific ID attributes on my webpage with JavaScript, and if they are activated, I want to execute some code. The code is working for a single attribute with document.querySelector
but not for document.querySelectorAll
.
I have tried the solutions posted here but without success, as I run into the following error:
Uncaught ReferenceError: Invalid left-hand side in assignment
My code is simple:
document.addEventListener('DOMContentLoaded', function(){
Array.from(document.querySelectorAll("#id_types, #id_cons_1")).forEach(button=>button.click()) = function() {
document.querySelector("#id_new_name").value= some_value_to_be_assigned
}})
What am I doing wrong?