Can someone quickly point out what I’m doing wrong and why ?
My intention is to have each .learnmore class to expand their own .more-content upon click.
jQ
$(document).ready(function(){
//Toggle function
$(".learnmore").click(function(){
$(this).next(".more-content").slideToggle(500)
return false;
});
});
HTML
<div class="wrapper">
<h2>Whatsup Stack!</h2>
<img src="/image.jpg" alt="Stack Overflow" />
<p>Quick, lorem Ipsum</p>
<p><a href="#" class="learnmore">Learn More</a></p>
<div class="more-content">
<p>Quick, lorem Ipsum</p>
<p>Quick, lorem Ipsum</p>
</div>
<!-- eo : more-content -->
Since its not a child of the element you are clicking you need to traverse up to the
.parentfirst. Then since its the next.more-contentafter the parent you can select it.Live Demo