Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
How to use JQuery to Wrap a specific list of div children

I am doing AB testing in google optimize. I need to wrap div from number 5 to 10 but I have not been able to do it:

<div class="container active" data-order="1">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<button>11</button>
<div>12</div>
</div>

I am using this code to do it but it start wrapping from div number one but I want to start with div number 5 until 10

$('.gsw_cf.step.active > div:lt(#)').wrapAll('<div class="wrapped 5to10"/>');

anyone knows what should I add?

Thank you

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can use jQuery's slice();

$('.active > div').slice(5,10).wrapAll('<div class="wrapped 5to10"/>');

$('.active > div').slice(5,10).wrapAll('<div class="wrapped 5to10"/>');
.wrapped{
background:red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container active" data-order="1">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<button>11</button>
<div>12</div>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

I found a solution that works where i use this function:

$('div[data-order="1"]').each(function(){
    $(this).children(".input_wrapper.text").wrapAll("<div class='wrapper' />");
});

I found that solution in http://jsfiddle.net/QWHYK/ and Wrapping sets of elements from a list in DIVs using jQuery

There is also, another solution in How to wrap multiple divs

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda