Reputation: 5
How to press at this button on js?
<button type="submit" class="btn-lg">Confirm</button>
i tryed this document.getElementsByClassName('btn-lg').Click();
but it not working.
Upvotes: 1
Views: 936
Reputation: 8181
document.querySelector(".btn-lg").onclick = function() { alert("clicked") }
Upvotes: 1
Reputation: 446
document.getElementsByClassName returns html collection (array-like object) of the objects which have a specified class. So you should filter unneeded elements by going through the collection (in the same way as you go through an array)
Upvotes: 0