Well, it seems to me that I missed something very simple, but here it goes:
This code works fine, exactly the way I want. You click on the link, and the next div is displayed (there are about 10 on the page)
$('a.addtask').click(function(){ $(this).next('.field').slideToggle(); return false; }); <div class="field"> Some content </div> <a href="#" class="addtask">Add a task</a> <div class="field" style="display:none;"> some other content </div>
However, I want to change the HTML like this (link inside a div):
<div class="field"> Some content <a href="#" class="addtask">Add a task</a> </div> <div class="field" style="display:none;"> some other content </div>
^^ What is not working properly.
What do I need to change in my jquery to make this work? I’ve been searching the Internet for a long time, and a number of solutions in such messages do not seem to work.
source share