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

232
Views
jquery: no se pueden encontrar elementos del objeto jQuery

Estoy obteniendo una cadena HTML y quiero construir un objeto jQuery a partir de ella y luego realizar operaciones, pero me estoy volviendo undefined .

 var data = '<h1>Hi World</h1'; var html = '<div id="rendered">'+data+'</div>'; //var content = $($.parseHTML(html)); var content = $.parseHTML(html); console.log($(content).find('#rendered').html()) // it says undefined
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

find() se usa para buscar elementos secundarios . #rendered es el nodo principal en la estructura HTML que crea, por lo que find() no devuelve nada. Debe usar filter() en su lugar, ya que eso incluye el nodo actual al buscar.

También tenga en cuenta que no se requiere $.parseHTML() ; jQuery lo hace automáticamente cuando proporciona una cadena con formato HTML al constructor del objeto jQuery.

 var data = '<h1>Hi World</h1'; var html = '<div id="rendered">' + data + '</div>'; console.log($(html).filter('#rendered').html())
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

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!