`Hey I was making a function but it seems onclick function is not working in google chrome extension and showing me the error
Basically my function is used to click all the checkboxes when I click on the button through add event listener which i read in stackoverflow here is the link of that post addEventListener calls the function without me even asking it to
After building that the thing is not working not sure what to do next
HTML CODE:
!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="body.css">
<title>Linkedin Extension</title>
</head>
<body>
<main>
<div class="main">
<H1 class="h1">Select All</H1>
<p class="p1">This is to Select all the checkboxes</p>
<button type="button" id="select-all" >Run me</button>
</div>
</main>
<footer class="end">Made with Love</footer>
<script src="script.js"></script>
</body>
</html>
Javascript Code
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("select-all").addEventListener("click", selectAll);
});
function selectAll(){
var inputs = document.getElementsByClassName("invitee-picker-connections-result-item__checkbox");
for(var i=0; i<inputs.length;i++)
{
inputs[i].click();
}
}
Let me know how this will code ran when I click on the html button
Here is the screenshot attached what it will do when it will run enter image description here
I want to run this code in an extension when I will click the button`