I've found a a few articles here on this topic but none seem to answer exactly what I'm looking for.
Here is my current code:
$(".email-slide").click(function(){
$("#panel").slideToggle("slow");
$(this)
.text("Close")
.toggleClass("active");
});
When I select the word "Email" which has the class "email-slide" the top panel slides down, and the word "Email" turns to white, and the word "Email" turns into the word "Close".
All good so far. But when clicking "Close" though the color and panel go back to normal, the word "Close" does not turn back into the word "Email". Instead of .text("Close") I tried .toggleText("class") but it seems that does not work. Is there something similar I could do it accomplish it by adding the least amount of code possible? Thank you!
UPDATE - I am able to accomplish it by using the following code, but was hoping that would be a more efficient/shorter way of doing it. If not, let me know. Thanks!
$(".email-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active");
});
$(".email-slide").toggle(function (){
$(this).text("Close")
}, function(){
$(this).text("Email")
});