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

122
Views
seleccione el elemento después de insertar jquery javascript

Tengo un pequeño problema que es el siguiente:

Tengo un botón que permite generar código html, ejemplo:

 $( "#addBlockArray" ).click(function() { let idunique = Math.floor(Math.random() * 100000); let array = '\ <divSpecialSelected class="selectedbloccss" id= ' + idunique + '> edit\ <table class="table table-hover" contenteditable="true"> \ <thead>\ <tr>\ <th scope="col">#</th>\ <th scope="col">First</th>\ <th scope="col">Last</th>\ <th scope="col">Handle</th>\ </tr>\ </thead>\ <tbody>\ <tr>\ <th scope="row">1</th>\ <td>Mark</td>\ <td>Otto</td>\ <td>@mdo</td>\ </tr>\ <tr>\ <th scope="row">2</th>\ <td>Jacob</td>\ <td>Thornton</td>\ <td>@fat</td>\ </tr>\ <tr>\ <th scope="row">3</th>\ <td colspan="2">Larry the Bird</td>\ <td>@twitter</td>\ </tr>\ </tbody>\ </table>\ </divSpecialSelected>\ ' $( "#blocArray" ).append( array); });

Sin embargo, cuando se genera este código, no puedo usar los selectores para realizar acciones en él.

 $("divSpecialSelected").on('click', function () { // that dont work, he dont find this selector console.log("aaa"); document.getElementById(this.id).addEventListener('mousedown', mouseDown, false); localStorage.setItem('id', this.id); window.addEventListener('mouseup', mouseUp, false);

});

Creo que porque no está en el DOM cargado al principio. Pero, ¿cómo podría evitar este problema?

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