I have two groups of links all with the same class names, the only difference is the text in the .
I need to get the text for the clicked link and pass it to GA through GTM.
<div class=item-set>
<header>Section Title One</header>
<section class=products>
<div class=list>
<a href=/Product/60216935><img src=/ProductImages1.jpg></a>
</div>
<div class=list>
<a href=/Product/6021693x><img src=/ProductImages2.jpg></a>
</div>
<div class=list>
<a href=/Product/6021693y><img src=/ProductImages3.jpg></a>
</div>
</section>
</div>
<div class=item-set>
<header>Section Title Two</header>
<section class=products>
<div class=list>
<a href=/Product/60216935><img src=/ProductImages1.jpg></a>
</div>
<div class=list>
<a href=/Product/6021693x><img src=/ProductImages2.jpg></a>
</div>
<div class=list>
<a href=/Product/6021693y><img src=/ProductImages3.jpg></a>
</div>
</section>
</div>
I have created a custom javascript variable
function() {
$('section.products div.list').click(function() {
return $(this).closest('.item-set').find('header').text();
});
}
But the bleep thing isn't working as I expect (or at all). It returns undefined.
Any assistance is greatly appreciated.