Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Cómo agregar wrapAll jquery o php después de etiquetas con la misma identificación

php

 <?php foreach ($forlop as $value) : ?> <?php $stringTitle = substr($value->getTitle(), 0, 1); ?> <?php if(is_numeric($stringTitle)){ echo "<h3 id='other'>0-9</h3>"; } else{ echo "<h3 id=".strtolower($stringTitle).">".strtoupper($stringTitle)."</h3>"; }?> <div class="item"><?php echo $value->getId(); ?></div> <?php endforeach; ?>
 <h3 id="c">C</h3> <div class="item">1</div> <div class="item">2</div> <h3 id="d">D</h3> <div class="item">3</div> <div class="item">4</div> <h3 id="e">E</h3> <div class="item">5</div> js $('[id]').each(function (i) { $('[id="' + this.id + '"]').slice(1).remove(); });

resultado deseado

 <h3 id="c">C</h3> <div class="items-add"> <div class="item">1</div> <div class="item">2</div> </div> <h3 id="d">D</h3> <div class="items-add"> <div class="item">3</div> <div class="item">4</div> </div> <h3 id="e">E</h3> <div class="items-add"> <div class="item">5</div> </div>

Quiero que se agrupen productos con las mismas iniciales, no tengo una solución efectiva. Quiero agregar una etiqueta contenedora a las etiquetas que tienen un elemento de clase en el bucle usando jquery. ¿Hay alguna forma de hacerlo? o tiene cualquier otro tratamiento déjeme saber acerca de sus ideas. Gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes resolverlo en php así:

 <?php $oldTitle = ""; ?> <?php foreach ($forlop as $value) : ?> <?php $stringTitle = substr($value->getTitle(), 0, 1); ?> <?php if($oldTitle !== $stringTitle && $oldTitle !== ""){ echo "</div>"; // close items add tag ?> <?php if(is_numeric($stringTitle)){ echo "<h3 id='other'>0-9</h3>"; } else{ echo "<h3 id=".strtolower($stringTitle).">".strtoupper($stringTitle)."</h3>"; }?> <?php if($oldTitle !== $stringTitle){ echo "<div class='items-add'>"; $oldTitle = $stringTitle; ?> <div class="item"><?php echo $value->getId(); ?></div> <?php endforeach; ?>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!