I need get all inputs of one page with a google extensioin.
My code is executed when charge a page. But I need make a button for this.
If I only write this:
var inputs = document.body.querySelectorAll('input');
The inputs var, content all inputs, fine..
But if I execute a function when push the button dont work.
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('rellena').addEventListener('click', al);
});
function al(){
var inputs = document.body.querySelectorAll('input');
alert("Hello")
}
In this example, the alert are executed fine, but not the querySelectorAll.
After that, I use loop for change the value of inputs. This work without button, but not with button.
PD: If i change alert for a console.log(inputs) don't work. If I put console(inputs )and imput var out of "al" function, this work.