I have a tab table with id of "eael-advance-tabs-d1be836" and it has smaller elements with no id in them but they have "class" assigned to them. I tried to change the code i once used with getElementById to getElementByClassName and it doesn't work, the goal is to make a action when specific element with specific class is clicked in page and scroll down 150 pixels lower code sample below Inspect element view The sample below works perfectly with using id by the elements in tab table have no id but only "class". Is it possible to edit this code so that it would work with 'getElementsByClassName' ?
Thank you!
<html>
<body>
<form>
<input class="cat" type="checkbox" id="myCheck" >
</form>
<p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p><p>text-text-text-text-text-text-text-text-text-text-text-text-</p>
<script>
var scrollAmount = 150;
var element = document.getElementById("myCheck");
element.addEventListener("click", scrollPage);
function scrollPage() {
var currentPositionOfPage = window.scrollY;
window.scrollTo(0, currentPositionOfPage + scrollAmount);
}
</script>
</body>
</html>