Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

262
Visualizações
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 Respostas
Responde à pergunta

0

Try:

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

using append().

over 4 years ago · Santiago Trujillo Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda