I’m using a plugin that creates a span class element based on a label I’ve defined in a separate javascript file.
I want to create an eventListener for when the checkbox has been checked and reference the text in the span class using jQuery.
However, I am not sure on how to reference the span class for each label class #leaflet-layerstree-header-label input.
Something like an example here that adds a map function to obtain the collection.
The element for each label is referenced as such:
<label class="layerstree-header-label">
<input type="checkbox" class="control-layers-selector">
<span class="layerstree-header-name">7211</span>
</label>
2
Answers
So I figured out I have to reference the container for the module in order to obtain the text for the selection. The solution that worked was as follows (with contribution from @Tushar):
You can attach the event listener on
change
event for the checkbox and use.siblings
to find thespan