title: Merge multiple tr with same value/ID in jquery
body: <p>Its been so long since I researched and found nothing. This was the problem I'm facing, I have a table, populated from database. All I want to do is to merge all the table rows <code>&lt;tr&gt;</code> with same value(patient ID) into one tr.</p>
  
  <p>For example I have four patients and one of them have gone through two studies:</p>
  
  <pre><code> Patiend ID       Patient Name     Study
      1111            Angela          XRAY
      2222            Bena            Ultrasound
      3333            Luis            CT Scan
      1111            Angela          Ultrasound
  </code></pre>
  
  <p>Aside from merging the same patient, the client also want to add "+" sign so that the client will know that that patient gone through 2 or more studies. And if the client click on the "+" sign, the merge table row will expand showing all the studies.</p>
  
  <p>All I have in mind is that after I'll check all the table rows and look for same patient ID, if it have, merge or hide that table rows and add "+". And every time the Doctor/ client click the "+" then it will expand.</p>
  
  <p>But I don't know how.</p>
  
  <pre><code> Patient ID       Patient Name     Study
      1111            Angela          XRAY   "+"
      2222            Bena            Ultrasound
      3333            Luis            CT Scan
  </code></pre>
  
  <p>If the "+" is clicked:</p>
  
  <pre><code> Patient ID       Patient Name     Study
      1111            Angela          XRAY  
      1111            Angela          Ultrasound
      2222            Bena            Ultrasound
      3333            Luis            CT Scan
  </code></pre>
  
  <p>So far, this was my code, just trying to alert, but this would alert all the "same".</p>
  
  <pre><code> $(".pid").each(function(n){
              var text = $(this).text();
              $(".pid").each(function(n){             
                  var text2 = $(this).text();
                  if(text == text2)
                  {
                      alert(text2 + "same");
                  }
              });
          });
  </code></pre>
  
  <p>Please help. </p>