Search code examples
javascriptgetelementbyid

How to handle click on button without ID but with value?


The third-party library provides web SDK with a button without ID but with value? So, I could not add the ID to it.

How to handle click (like getElementbyId) and add the listener to it?

<input value="Some Value">

Solution

  • You can use querySelector for that to get the input with a specific value, like that

    document.querySelector('input[value="Some Value"]');