Jquery toggle keeps repeating on the second tab

here is my code:

// hide the content
  $(".maintitles_jd").hide();
	
  $(".dad h3").click(function(){
    $(this).next(".maintitles_jd").stop(true, true).slideToggle()
     .siblings(".maintitles_jd:visible").stop(true, true).slideUp();
    $(this).stop(true, true).toggleClass("active");
    $(this).siblings(".dad h3").removeClass("active");
  });
});

The code above is working fine on the first tab, but when a second tab is generated and when clicked on toggle div it keeps repeating.

Help!

Hi,

Could you possibly post a link to a page where I can see the problem?
Also, what do you mean, “when a second tab is generated?”

Sure it won’t be too hard to sort out :slight_smile:

I can not send you a link to the site as its confidential, but here are the code that im tryin to archive:

$(document).ready(function(){
	
	// hide the content
  $(".maintitles_jd").hide();
	
  $(".dad h3").click(function(event){
		event.stopPropagation();
    $(this).next(".maintitles_jd").stop(true, true).slideToggle()
     .siblings(".maintitles_jd:visible").stop(true, true).slideUp();
    $(this).stop(true, true).toggleClass("active");
    $(this).siblings(".dad h3").removeClass("active");
  });
});
<?php 
		
				require_once("../php_engine/_php_xml.php");
				
				if( isset($_POST["qsurvey"]) && isset($_POST["qjobnumber"]) ){
					$x = new aj_xml($_POST["qsurvey"],$_POST["qjobnumber"]);
				}else{
					$x = new aj_xml('LOCL','10.02',true);
				}
				
				if($x->file_does_exist == true){					
					$title_txt = "Job Description";
					
					echo("<div class='dad'>");
					echo("<h3 id='jd'>" . $title_txt . "</h3>");
					echo("<div class='maintitles_jd' id='jd_content' style='display: none'>");
					
					$x->readxml_jd();								
					
					if(isset($x->values)){
						foreach($x->values as $key=>$value){
							if($value!=''){
								if( is_numeric($key) ){
									echo "<p class='lines'>" . $value . "</p>";
								}

								if( !is_numeric($key) ){
									echo "<div class='lines'><span class='heading_jd'>" . $key. "</span>" . $value . "</div>";
								}
							}
						}
					}	
								
						echo("</div>"); // end of jd_content DIV
						echo("</div>");// end of dada DIV	

				}// end if($x->file_does_exist == true)
?>

Fair enough, but I can’t do very much with the PHP you posted.
Would it be possible for you to navigate to the page you are having trouble with, then look at the source code (Ctrl + U in most browsers), copy it and post it here?
I just need to be able to reproduce the problem you are having.