Posted By

aristoworks on 04/10/09


Tagged

jquery multiple divs


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

vali29
esritter
lori
ColdCoffee


jQuery - Toggle Multiple Elements


 / Published in: jQuery
 

URL: http://www.aristoworks.com

I used this simple snippet to enable users to "View More Info" which was embedded in a div below each of a list of items. This is different from many of the simple jQuery examples that only allow you to show/hide one particular div.

  1. <!-- jQuery Code -->
  2. $(document).ready(function() {
  3. $('#commentbox').hide();
  4.  
  5. $('a.comment').click(function() {
  6. var id = $(this).attr('id');
  7. $('#commentbox' + id).toggle(500);
  8. // alert(id);
  9. return false;
  10. });
  11.  
  12. });
  13.  
  14.  
  15. <!-- HTML -->
  16.  
  17. <div class="story">
  18. <div class="storytitle">hello</div>
  19.  
  20. <div class="storybg">blah blah blah</div>
  21. <div class="storybottom"><a href="#" id="3242" class="comment"
  22. name="3242">comment</a></div>
  23. <div id="commentbox3242" class="commentbox"
  24. style="display:none">comment form</div>
  25. </div>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: fit20 on April 20, 2009

id="3242" is not conform html code ...

Posted By: MrCrumbs on December 29, 2009

Hi,

How can I alter this code, so when it reveals the comment box it hides the link to open the comment box?

e.g. hide: comment

Thanks

Posted By: MrCrumbs on December 29, 2009

Hi,

How do you make it so when you click "Comment" to reveal the comment box, it also actually opens a link as well.

e.g.

< div class="storybottom3242">comment

Posted By: MrCrumbs on December 29, 2009

Hi,

How do you make it so when you click "Comment" to reveal the comment box, it also actually opens a link as well.

e.g.

< div class="storybottom3242">comment

You need to login to post a comment.