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

312
Vistas
jQuery: add content to end of div

I have this HTML:

<div class="region-list" id="region_North_America">
    <strong>North America</strong>
</div>

and want to add more divs after the strong element to result:

<div class="region-list" id="region_North_America">
    <strong>North America</strong>
    <div> ... </div>
    <div> ... </div>
    <div> ... </div>
</div>

I am trying this:

var row_str = '<div>content here</div>';
$('#region_North_America div:last').html(row_str);

However, there is no change to the html. This is probably so since there is no div within the element selected.

I know that the js is making it to this code because I can print the content of row_str to the console.

So, how can I get to the end of that container element to add the new items?

Thx.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Try:

$("#region_North_America").append(row_str);

using append().

over 4 years ago · Santiago Trujillo Denunciar

0

Or:

$("<div>content here</div>").appendTo("#region_North_America");

To create the element on the fly, and place it in the document.
Using the appendTo method.

over 4 years ago · Santiago Trujillo Denunciar

0

Your code will just place html in the last div within #region_North_America. Use the append function.

$("div.region-list").append(row_str);
over 4 years ago · Santiago Trujillo 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