How can I create a toggle effect on the :after property, switching between + and - each time the link is clicked?
I've attempted to achieve this using JavaScript, CSS, and HTML, but the code only changes + to - and doesn't switch back when the link is clicked again.
$("#heading1").click(function(){
document.querySelectorAll('#heading1')[0].style.setProperty("--content","'—'");
}
#heading1:after {
content:var(--content,"+");
}
<a id="heading1">link</a>