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

310
Views
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 answers
Answer question

0

Try:

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

using append().

over 4 years ago · Santiago Trujillo Report

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 Report

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 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!