[JQuery] Hide all other divs?

I’m making an forum script with expandable comment boxes, and this works just fine ecxept 1 thing… When a comment div is expanded all other comment divs should close back… How do I do so?

jQuery(document).ready(function() {
  jQuery("#content_full_<?=$newsid;?>").hide();
  jQuery("#content_small_<?=$newsid;?>").show();
  //toggle the componenet with class msg_body
  jQuery("#heading_<?=$newsid;?>").click(function()
  {
	jQuery("#content_full_<?=$newsid;?>").fadeIn();
	jQuery("#content_small_<?=$newsid;?>").hide();
  });
});

Thanks in advance :wink:

You could give all your divs that will be contracting and expanding a common class name, this way is easy to target all of them at once from jquery.


jQuery( "#heading_<?=$newsid;?>" ).click(function()
{
    jQuery( ".all_divs" ).each( function(){ $( this ).hide(); } ); 
    jQuery( "#content_full_<?=$newsid;?>").fadeIn(); 
});