I’m having a issue trying to built a nice “products” page, I have the html:
<div class="product-box-2">
<a href="img/produtos/1-lightbox.jpg" class="lightbox"><img src="img/produtos/1.jpg" alt=""></a>
<p class="legend">>> Vero mlkshk velit, freegan ullamco commodo put a bird on it cred synth kogi, Vero mlkshk velit, freegan ullamco commodo put a bird on it cred synth kogi.</p>
<a href="img/produtos/1-lightbox.jpg" class="ampliar lightbox">clique para ampliar</a>
</div>
<div class="product-box-2">
<a href="img/produtos/1-lightbox.jpg" class="lightbox"><img src="img/produtos/1.jpg" alt=""></a>
<p class="legend">>> Vero mlkshk velit, freegan ullamco commodo put a bird on it cred synth kogi, Vero mlkshk velit, freegan ullamco commodo put a bird on it cred synth kogi.</p>
<a href="img/produtos/1-lightbox.jpg" class="ampliar lightbox">clique para ampliar</a>
</div>
And so many times it’s needed. And then I try to put a nice effect on the .legend, with CSS to seting “display:none” and the Jquery:
$('.product-box-2 a').mouseenter(
function(){
$('.legend').fadeIn();
});
$('.product-box-2').mouseleave(
function(){
$('.legend').fadeOut();
});
But I have the same classes, and so, all legends appear when I put my mouse over some of the .product-box-2 a… And I have no idea how to select only the .legend inside the .product-box-2 a there I’m in.
If you want to see this in action, here it is!
Restrict the scope of the inner selector to the element on which the event occurred by giving it the element as the context. See the docs for the signature that accepts a context.