I’m having a simple problem toggling between +/- characters which prepend a link which opens a dropdown menu. This code works, except I need to remove the div and just have the href toggle.
Any help is appreciated.
HTML:
<a href="#" class="toggler"><span>+</span> toggle</a>
<div class="hidden">
Hidden
</div>
jQuery:
$('a.toggler').click(function() {
var $this = $(this);
$this.next(".hidden").slideToggle("fast", function() {
$this.find('span').text($(this).is(':visible') ? '-' : '+');
});
});
I borrowed the code from this link: Need to replace +/- characters with html codes (for example) — in small piece of jQuery
Here is an updated version:
http://jsfiddle.net/aGKJR/2/
I had it so it only toggled when you clicked the +/-. Now the whole link works.
Basically, you need to remove the
slideTogglecallback and place its code in theonclickfunction instead.