I create some divs with this snippet
for (let index = 0; index < data.length; index ++)
{
if (lastFriendInsert != data[index]['friend']['name'])
{
$('.data').append(
'<div class="friend friend'+index+'">' +
'<span class=\'dataKey\'>Name: </span><span class=\'dataValue\'>' + data[index]['friend']['name'] + '</span><br>'
'</div>'
);
if ( data[index]['whoIsTagged'] != null && data[index]['taggedTogetherCount'] != null)
$('.friend'+index).append(
'<div class=" btn istaggedWithbtn istaggedWithbtn'+index+'">Show who is tagged with</div>' +
'<div class="istaggedWith istaggedWith'+index+'"></div>'
);
lastIndexInsert = index;
taggedWith(data,lastIndexInsert,index);
}
lastFriendInsert = data[index]['friend']['name'];
}
So I have the following structure:
data
|_friend0
| |_istaggedWithbtn istaggedWithbtn0
| |_ istaggedWith istaggedWith0
|
|_friend1
|_istaggedWithbtn _istaggedWithbtn1
|_istaggedWith istaggedWith1
The divs istaggedWith
are hidden with the property display:none;
I want to click on the istaggedWithbnt1
and show just the related div istaggedWith
; in this case istaggedWith1
. How can I do this?
I write just the following code to enable the click event on the button, but I can't show the related div
$('.data').on('click', '.istaggedWithbtn',function(){
...
});