I tried to solve it, I succeeded somewhat, but now I'm stuck.
I have this structure:
<h4>title</h4> <p>text</p> <hr /> <h4>title</h4> <p>text</p> <p>text</p> <hr /> <h4>title</h4> <p>text</p> <hr />
What I'm mostly trying to accomplish is to toggle the words tonen (meaning open) and verbergen (which means hide) while shifting P up and down. Right now I am adding a span with the word tonen and checking if it is shown or not.
The content is hidden during loading, the tone is displayed, but when h4 is clicked, the content is displayed, but the tone does not change to verbgen. I read about life and life, but I do not understand.
<script> $(function(){ $("h4").append("<span> - tonen</span>"); $("h4").nextUntil("hr").hide(); $("h4").click(function () { $(this).nextUntil("hr").slideToggle("fast"); if(span.text() == " - tonen"){ span.text(" - verbergen"); } else { span.text(" - tonen"); } }); }); </script>
source share