0

I have a webpage, in which there are few elements and I've found using Chrome Developer Tools that an element is bound to onmousedown event listener

For reference, this is the link to the webpage : http://zzzscore.com/1to50/en/

And in that page there are 25 blocks numbered from 1 - 25. The HTML code for the blocks is like this

<div style="opacity: 1;">
    <span class="box" style="z-index:99"></span>
    1
</div>

<div style="opacity: 1;">
    <span class="box" style="z-index:90"></span>
    2
</div>

and so on. Here I can't see any onmousedown event being explicitly called, but the numbers get changed to other numbers on clicking them (some function should be doing this). Also, If I remove the event listener from chrome dev tools, no change happens on clicking (So somehow, the event is registered with the elements).

Basically, I'm writing a Javascript function to click these numbers but it's not working (Though it works for click on some other buttons). My code is something like this

var element = document.getElementsByTagName("div")[12];  // First block from the total 25 blocks
element.click();

So, how can I find on which element, I need to do the mouseDown/click task so that it works just like a regular mouse click?

Vishal Afre
  • 1,013
  • 3
  • 12
  • 39
  • Instead of direct click try dispatching click event: [How to simulate a click with JavaScript?](https://stackoverflow.com/q/2705583) – wOxxOm Sep 20 '16 at 08:50
  • @wOxxOm tried it but didn't work... Also FYI, I'm calling the `eventFire` function with "div" as the element and "click" as event ("mousedown" and "mouseup" is also not working). Am I doing it right or it should be something else? – Vishal Afre Sep 20 '16 at 15:55
  • Notice that `app53b2709a.js` contains the js specific to this app. If you beautify it (the {} button in chrome's devtool) you can see on lines 49 and 54 that the events being listened for are actually `touchstart`, `tap` and `touchend` – enhzflep Sep 21 '16 at 16:39
  • @enhzflep `touchstart`, `touchend` and `tap` are not of my interest as if I remove all the event listeners except the `mousedown`, cicking on the blocks still works perfectly, but it stops as soon as I remove `mousedown`. So my question is with my external js function, how can I replicate this click functionality – Vishal Afre Sep 22 '16 at 04:26

0 Answers0