I want that my code is clicking the first button on an ul item.
Here is what i found and tried, but its not working…
let player_input = document.querySelectorAll('ul.playerResultsList button')[0];
custom_event = new Event('click');
player_input.dispatchEvent(custom_event);
custom_event = new PointerEvent('click');
player_input.dispatchEvent(custom_event);
custom_event = new MouseEvent('click');
player_input.dispatchEvent(custom_event);
does anyone have an idea? I also tried click() as well.
The page has an input field. When i type in few letters, than it shows some finds.
I can now click one i want, and than its done.
But now i want to click it automatically the first item but my code does not work.
This is how the HTML Element looks like
<ul class="ut-button-group playerResultsList">
<button class=""><span class="btn-text">row 1</span><span class="btn-subtext">89</span></button>
<button class=""><span class="btn-text">row 2</span><span class="btn-subtext">73</span></button>
<button class=""><span class="btn-text">row 3</span><span class="btn-subtext">72</span></button>
<button><span class="btn-text">row 4</span><span class="btn-subtext">72</span></button>
<button class=""><span class="btn-text">row 5</span><span class="btn-subtext">70</span> </button>
</ul>
I tried dispatchEvents but that is not working. Also click() does not work