I have a <div>
containing a <a>
tags and further divs:
<div>
<div class="icons">
<div class="group popOutDisplay">
<a href="#" data-id="128910"><i class="fa fa-home"></i></a>
<a href="#" data-id="239019"><i class="fa fa-search"></i></a>
<a href="#" data-id="346653"><i class="fas fa-bicycle"></i></a>
</div>
<div class="group">
<a href="#"><i class="fa fa-globe"></i></a>
</div>
<div class="group bottom">
<a href="#"><i class="fa fa-trash"></i></a>
</div>
</div>
<div class="content">
<div id="128910";>
<p>some content</p>
</div>
<div id="239019";>
</div>
<div id="346653";>
</div>
</div>
</div>
Im trying to select the data attribute on the anchor tag with jquery so that i can display the the <div>
tags in <div class="content">
which have the same ID (if that makes sense?).
So far i've been able to identify the data id with
$(".group.popOutDisplay a")[0].attributes[1].value;
but this only gives the ID of the first element, due to the [0]
index.
tldr:
How can I get the data-ID of the <a>
tag that has just been clicked?