title: How to connect two elements with same id's
body: <p>I have a wordpress custom post type and i have displayed them like this </p>
  
  <pre><code>&lt;?php
              $count = 1;$counter = 1;
              $query = new WP_Query( array('post_type' =&gt; 'companyhistory', 'posts_per_page' =&gt; -1, 'order' =&gt; 'ASC' ) );
              while ( $query-&gt;have_posts() ) : $query-&gt;the_post(); 
  
          ?&gt;
          &lt;div class="companyhistoryitem history_year&lt;?php echo $count;?&gt;" id="&lt;?php echo $count;?&gt;"&gt;&lt;?php the_title();?&gt;&lt;/div&gt;
          &lt;div class="company_historycontent history_year&lt;?php echo $count;?&gt;" id="&lt;?php echo $counter;?&gt;"&gt;&lt;?php the_content();?&gt;&lt;/div&gt;
              &lt;?php $count++;$counter++; endwhile; wp_reset_query();?&gt; 
  </code></pre>
  
  <p>I wanted to show corressponded content on click on the .companyhistoryitem .I am tring to connect them with this jquery code but no luck </p>
  
  <pre><code>jQuery('.companyhistoryitem').each(function(){
      jQuery(this).click(function(){
          var historytitleid = jQuery(this).attr('id');
          jQuery('.company_historycontent').each(function(){
              var historycontentid = jQuery(this).attr('id');
              console.log(historycontentid);
          });
          var aaa  = jQuery('.company_history_section .maincontainer').find('.company_historycontent').attr('id' , historytitleid);
          if(historytitleid == aaa){
              console.log(aaa.html());
          }
      });
  });
  </code></pre>