I've got a problem that's been racking my brain since I'm rather inexperienced with programming. I'm a member of a website that hosts image galleries. When you view a page with a list of galleries, every gallery has tags underneath it inside of icons.
<div class="id4">
<a href="..."><img src="..."></a>
<div class="id44">
<div class="tft" title="tag1, tag2"></div>
<div class="tft" title="tag3"></div>
</div>
<div class="tags"></div>
</div>
<div class="id4">
<a href="..."><img src="..."></a>
<div class="id44">
<div class="tft" title="tag1"></div>
<div class="tft" title="tag2"></div>
</div>
<div class="tags"></div>
</div>
Since hovering over each icon is a big hassle, I wanted to write a custom script that writes the tags inside of the "title" attribute underneath the gallery they belong to. This is as far as I could get:
$(".id44").after('<div class="tags"></div>');
$(".id44").each(function() {
var array = [];
$(".tft").each(function() {
var tags = $(this).attr("title");
array.push(tags);
});
console.log(array);
});
All it does is print a gigantic list of every single tag on the page to the console as many times as there are galleries.