Stevan Tosic
Stevan Tosic

Reputation: 7199

ReactJs - trigger click on element with class

This is generated element by the plugin

<span class="leaflet-draw-draw-polyline">...</span>

I want to click on an element from some other part of the code.

How can I trigger click on this element without using ref on it?

Upvotes: 0

Views: 525

Answers (1)

Victor
Victor

Reputation: 14583

Since the element seems to be completely out of a React component's scope, you could try either of the following:

  1. create a React component and use refs
  2. simply use document.getElementsByClassName() and .click()

Upvotes: 1

Related Questions