On the page there are several elements with data
attributes. To avoid going to add CSS classes to the elements, making the page code denser, I would like to select elements by the name of the data
attribute.
Example
<div id="myDiv" class="text banana" data-my-target="John"></div>
<div id="myOther" class="text bread" data-my-target="Doe"></div>
<div id="myBother" class="text fun" data-my-girl="Jane"></div>
The idea is to apply certain action via jQuery to elements that contain a data-my-target
attribute.
Question
How can I select elements by the name of the data
attribute?