-1

I tried using document.getElementsByName but that didn't work for me. I'm trying to click a button, but I can't use document.getElementById because it does not have an id.

This is the button:

<div id="ApplyButton">
<br>
<br>
<input class="submitBtn" onclick="{ _onclick_1(arguments[0]);}" type="button" value="Apply">
</div>
AndrewG
  • 1
  • 2
  • provide the html example with the button which you want to click – ztadic91 Nov 23 '17 at 21:11
  • Please put your html and javascript into the question, wrapped in code tags. – James Nov 23 '17 at 21:13
  • I added the html. – AndrewG Nov 23 '17 at 22:07
  • There are several questions already answering different ways to select elements in javascript. E.g. [this answer suggesting the `querySelector()`](https://stackoverflow.com/questions/21975881/how-to-select-element-that-does-not-have-specific-class), or [this one on how to use `selectElementsByClassName`](https://stackoverflow.com/questions/17965956/how-to-get-element-by-class-name). And [one discussing `getElementsByTagName`](https://stackoverflow.com/questions/1666881/javascript-getelementsbytagname). – agrm Nov 23 '17 at 22:21

1 Answers1

0

You can use Document.getElementsByClassName() to get it via class.

If you are using jQuery, you can use $('.class-here') or with custom attr like $('[name="ElementNameHere"]').doStuff();

You can replace name with any custom attr.

zeeks
  • 775
  • 2
  • 12
  • 30