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

276
Views
how to append an element as a first child in jquery

lets say i have html something like this..

<ul id="leftNavigation">
  <table id="leftNavTable"><tr><td>blablabla</td></tr><table>
  <li>1</li>
  <li>2</li>
</ul>

what i want to do is when i click on any li, then that table should get hide and another table should get appended in place of that table.lets say that table is

<table id="Selected"><tr><td>blablabla</td></tr><table>

how to do it in jQuery.

i tried in this way but its adding as a last child of ul.

$('#leftNavigation').append('<table id="Selected"><tr><td>blablabla</td></tr><table>')

Thanks in advance!!!!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use .prepend() or .prependTo() instead.

Check jQuery documentation.

Additional notes

But based on what you're trying to accomplish you should maybe rather use DOM replacement functionality.

Beware

Adding anything else than LI inside an UL or OL is invalid HTML.

I suggest you add an additional LI, give it some ID or CSS class and then manipulate its content.

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!