Search code examples
javascriptdom-events

Is it possible to click this button with .click()?


I'm trying to figure out a way to click this with JavaScript's .click()

<input type="button" class="button" value="Test">

Is there a way to do that with the given attributes or do I need to add more (Id or Name) so I can use getElementby?


Solution

  • you could do it with getElementsByTagName("input") and look for items with an attribute type of button-- but you're better off getting it with an id attribute.