I'm using the slidetoggle function to open & close a box when clicking on a link. I want to be able to add a "close" button (link) inside that box aswell as being able to close it via the slidetoggle trigger. How would i do this?
This is my jQuery:
$(".popup-b").hide();
$(".popup-l").click(function(){
$(this).toggleClass("active").next().slideToggle(0);
return false;
});
My HTML
<a class="popup-l" href="#">Areas</a>
<div id="area-p" class="popup-box">
<div class="close-this"><a href="#">Close</a></div>
<p>This is the popup box</p>
</div>
jQuery:
HTML
Check out this Fiddle to see it working.
This way the
active
class will be setted when the close link is used too.You can also have many
.popup-box
on the same page.