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

176
Views
Cómo usar querySelector en un PopUp Modal

 const pokemonContainer = document.getElementById('pokemonContainer'); pokemonContainer.innerHTML += ` <div> <section class="all-comments"></section> </div> `; const allComments = document.querySelector('.all-comments'); allComments.appendChild(<h1>Hello World</h1>);
 <div class="row" id="pokemonContainer"></div>

Estoy intentando querySelector('.all-comments') pero como está en pokemonContainer, es por eso que regresa indefinido. ¿Alguien puede guiarme sobre cómo consultar seleccionar algo colocado en innerHTML como se indicó anteriormente?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Node.appendChild() espera un elemento de nodo como parámetro, puede crear un nodo de texto usando Document.createTextNode() :

 allComments.appendChild(document.createTextNode('Hello World'));

Manifestación:

 const pokemonContainer = document.getElementById('pokemonContainer'); pokemonContainer.innerHTML += ` <div> <section class="all-comments"></section> </div> `; const allComments = document.querySelector('.all-comments'); allComments.appendChild(document.createTextNode('Hello World'));
 <div class="row" id="pokemonContainer"></div>

Actualización: no puede pasar <h1>Hello World</h1> directamente a appendChild() . Primero debe crear un nodo del tipo que desee, luego establecer el texto y finalmente pasar ese nodo al método.

O: puede intentar usar Element.insertAdjacentHTML()

 const pokemonContainer = document.getElementById('pokemonContainer'); pokemonContainer.innerHTML += ` <div> <section class="all-comments"></section> </div> `; const allComments = document.querySelector('.all-comments'); allComments.insertAdjacentHTML('beforeend', '<h1>Hello World</h1>');
 <div class="row" id="pokemonContainer"></div>

about 4 years ago · Juan Pablo Isaza 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!