To find the clicked anchor, use something like

$("a.closed").click(function() {
  var a = $(this);
  var aEl = a[0];
})

To find all the content after the anchor until the next h3 or h4, use this
nextUntil function, written by John Resig:

http://docs.jquery.com/JQuery_1.2_Roadmap#.nextUntil.28.29_.2F_.prevUntil.28.29

Here are two examples:

http://dev.jquery.com/~john/jquery/test/nextuntil.html
http://benjaminsterling.com/jquery-select-what-you-want-part-2/#javascript-24

- Richard

On Dec 26, 2007 3:49 PM, jerpod <[EMAIL PROTECTED]> wrote:

>
> I suspect this is extraordinarily simple,  but I've yet to find a way
> to do it so bear with me (very new to jquery).
>
> My mission is to allow a user to click on a link of css class
> "closed" (the content below that point in the DOM will be hidden).
> When that link is clicked the content will .show(), or
> maybe .toggle().
>
> My first issue is that there may be several links of the class
> "closed" on the page.  I need to select only the DOM content "below"
> that link -- ie, everything (I think) from the link up to the </body>
> tag.  So I need to know which link was clicked (the links will NOT
> have IDs -- neither will anything else in the DOM).  How do I say with
> jquery, "select everything from the link that was clicked through the
> end of the document"?
>
> My next issue (which I can tackle after my first problem is resolved),
> is that I will need to loop through the returned object, toggling open
> or closed, until I reach the next instance of an h tag (actually,
> either h3 or h4). At that point I'll bail out of the loop.
>
> So the effect is pretty simple:  When the user hits the page, there
> are a bunch of "closed" sections.  By clicking the link the user
> "opens" one or more of those individual sections.  What makes it
> difficult is that fact that I need to enable some non-html-savvy
> person to add new content through an admin (CMS) interface, and have
> that person be able to add the code to necessary to do the open/close
> routine.  I think I can do all this with jquery, and all the admin
> user would need to do is add the "closed" class to the link. Does that
> make sense?
>
> All help appreciated.
>
> jp
>
>

Reply via email to