0

There is a list on a website and I am trying it simulate a click on that list item. Normally, if I click the list item with the mouse, it gets selected.

The website is created with React. I can see it in React Dev Tools too.

enter image description here

enter image description here

enter image description here

I tried combinations of these on the <li> element:

$($0).click();
$($0).trigger('click');
$($0).mouseover();
$($0).trigger('mouseover');
$($0).mouseenter();
$($0).trigger('mouseenter');

What is the proper way of achieving it?

P.S: The website is 3rd party and I am trying to perform the click via chrome extension - content script (basically with injecting my script in a 3rd party page)

The website is Facebook Ads Manager > Traffic

enter image description here

4
  • document.querySelectorAll('._hpt li')[2].click(); Commented Jul 21, 2017 at 16:09
  • document.querySelectorAll('._hpt li')[2] selects but .click() doesn't do the trick. I said I tried .click(). I put the link in the question, you can try it yourself Commented Jul 21, 2017 at 16:11
  • Are you sure you need click() and not focus()? You also might need to target a click-able or focus-able element that's deeper than the <li> you've selected. Is there an anchor tag in there? Commented Jul 21, 2017 at 18:44
  • I didn't quite get what you mean. In react dev tools, it shows that it's mouseDown & mouseEnter; that's why I started suspecting that it is not click. But I want to try your solution, if you can expand it more code-wise. Thanks for your time. Also, I added a link in the question if you want to try it yourself Commented Jul 21, 2017 at 18:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.