D
D
developer0072017-06-04 20:13:05
JavaScript
developer007, 2017-06-04 20:13:05

How to emulate clicking on react elements?

There is an application written in react and there is jquery. It is
necessary to get selectors to the element from the chrome console and call click

<a href="#" class="dealbtn dealbtn-up" data-reactid=".2.1.0.1.0.0.1.0.0.0" style="display: inline-block;">test</a>

Here's an element
I get it like this and call a click $(".dealbtn-up").click(); - not pressed. I tried many options
and events like mouseup - but it does not work.
Clicking the mouse works.
what is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-06-04
@developer007

If you're on someone else's site trying to $ something there, then you need $ to be equal to the jQuery function, because in fact, $ is just a function name.
Therefore, for starters, enter $ in the console, it should be something like this:
But not like this:
Okay, let's say jquery is connected and accessible through $, then check that this element is available:
If it is available and it is only one (!) , then we go further and check if the click function is available (this is already from the realm of fantasy, since it should be 100% available, but you never know what was written by another programmer, the main thing in this answer is for you to understand the sequence of actions).
Looks like this .
If there are many such links, then you need to access the element by index, for example:
$(".dealbtn-up")[0].click()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question