I have a div which collapses clicking on a text header. I want to change the header from "+ filters" to "- filters" accordingly (when the div is collapsed or expanded)
How can I perform this with jQuery?
if (headerDiv.text() starts with "+")
replace "+" with "-"
else
replace "-" with "+"
Never mind, I figured it out
if ($(header).text().trim().charAt(0) == "+")
$(header).text($(header).text().replace("+", "-"));
else
$(header).text($(header).text().replace("-", "+"));
If this is not the correct way, I'd appreciate a heads up
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With