Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
Agregue lapso para un índice específico sin que se eliminen los eventos

Estoy tratando de agregar intervalos a un índice específico en el HTML interno de la página.

cuando reemplazo el viejo innerHtml con el nuevo> todos los eventos en la página no funcionan

luego me doy cuenta de que innerHtml hace que los eventos no funcionen >>

Entonces, ¿cómo puedo hacer esta operación sin perder los eventos en la página?

aquí está mi código: -

 var startInd = [50]; //the index of word in innerHtml var lastInd = [55]; //the last index of word in innerHtml(its length)(the spanned area) var str = document.body.innerHTML; var count = 1;
 for (let j = 0; j < count; j++) // count always 1 { let pre = str.substring(0, startInd[j]); // all html elements before the word let post = str.substring(lastInd[j], str.length); // all html elements after the word let phrase = str.substring(startInd[j], lastInd[j]); // the word let nextPhrase; if (j < count - 1) { nextPhrase = str.substring(startInd[j + 1], lastInd[j + 1]); } str = pre + `<span id="myHeader${i}">${phrase}</span>` + post; // make the new innerHtml newID = "myHeader" + i; if (j < count - 1) { startInd[j + 1] = str.indexOf(nextPhrase, startInd[j + 1]) - 1; lastInd[j + 1] = startInd[j + 1] + nextPhrase.length; } document.body.innerHTML = str }
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda