Sorry for the vague subject, I rewrote it a few times and it still
doesn't make much sense, hopefully what I say below does.

I'm trying to implement jQuery into my comments to enable users to
show/hide them as they read them.

My problem occurs that using my current jQuery code, every comment div
gets closed when clicking on one, while I would like it to only close
the div the user clicks on. The comment itself is wrapped in a <div
class="comment"></div> while the Show/Hide links are within a <ul> in
the <div> (explaining the not('ul') part of my code).

My comment div looks something like this:

<div class="comment">
  <ul><li class="show-comm-single"><a href="#" title="Show
Comment">Show</a></li><li class="hide-comm-single"><a href="#"
title="Hide Comment">Hide</a></li></ul>
  <div class="content"><p>comment here</p></div>
</div>

And my jQuery code:

        $('li.hide-comm-single').click(function(){
                $('.comment').children().not('ul').hide();
                return false;
        });

With the current code, each comment on my page is hidden (so for
example, if the page has 3 comments, and I only mean to click the
first comment, but clicking it closes the other 2 comments as well).

My question, is it possible to write the code so that 1 <div
class="comment"> at a time is closed instead of every one? Is there
something I'm missing that allows just a unique .comment to be closed
without having to use something silly like css ids.

Reply via email to