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

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

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