I need to auto-click on a class button (help)

I need to auto-click on this button:

<button tabindex="-1" class="btn btn-inverse btn-large"> Botao1 </button>

But there are several equal classes, I have tried to use the [number].click to set the specific click, only the number sometimes changes, dai click on a different button.. I need help to click exclusively on the button above.

Author: lololololo, 2019-03-11

1 answers

You can put a new element called id in <button>, it would look like this:

<button tabindex="-1" class="btn btn-inverse btn-large" id="myButton"> Botao1 </button>

By doing this you can catch the click event of this element by jQuery:

$("#myButton").click(function() {
  console.log("Button click!")
})

Or, if you're using pure javascript, you can do the following:

document.getElementById("myButton").onclick = function() {
    console.log("Button click!")
}
 0
Author: Lucas Prochnow, 2019-03-12 00:12:43