0

Imagine there is a List item called one. When you click on this List item it opens a new page. I want to click on the List item with a js code input via the google chrome console (without button...).

The id of the Li is: one

document.getElementById("one").click();

When i put that in the console it doesn´t work.

1 Answers1

0

The .click() is not cross browser compatible.

Use .onclick() instead.

See related question

tpayne84
  • 181
  • 1
  • 9
  • This does work: here are a few things to verify 1. You are resolving an element from the `document.getElementById("one")` call. 2. You have assigned a click handler... example => `document.getElementById("one").onclick = function() { alert("test") };` – tpayne84 Dec 26 '18 at 16:48