Reputation: 173
Im trying to make the "Minus" sign turn back into the plus sign after the user has closed the expendable text.
Here is the code HTML
<p class="textDropTitle"><span class="textDropLogo"></span>Title</p>
<div class="textDropSub"><p>This is my text Below</div>
<p class="textDropTitle"><span class="textDropLogo">+</span>Title</p>
<div class="textDropSub"><p>This is my text Below</div>
<p class="textDropTitle"><span class="textDropLogo">+</span>Title</p>
<div class="textDropSub"><p>This is my text Below</div>
jQuery
$(".textDropSub").hide();
$('.textDropLogo', this).text('+');
$(".textDropTitle").click(function() {
$(this).next().toggle('fast');
$('.textDropLogo', this).text('-');
});
Upvotes: 3
Views: 54
Reputation: 206121
Quite simple using a Conditional Ternary Operator (?:)
$(".textDropTitle").click(function() {
$(this).next().toggle('fast');
var $el = $('.textDropLogo', this);
$el.text( $el.text() == '+' ? '-' : '+' );
});
[condition] ? [if is true] : [if is false] ;
Upvotes: 2