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

408
Views
".innerHTML" no se muestra correctamente en Safari (JavaScript)

Mi problema:

Hola a todos,

Actualmente estoy tratando de escribir un código simple que tome cadenas específicas y las ponga en negrita usando solo JavaScript. El código funciona bien, pero cuando lo probé en un dispositivo móvil, noté que no muestra correctamente la cadena recién resaltada.

En cambio, no muestra nada.

¿Puede alguien ayudarme con esto?

Lo que he probado:

Pensé que tal vez, dado que estaba reemplazando el texto usando ".innerHTML" en lugar de ".innerText", estaba causando algún tipo de problema, sin embargo, necesito usar ".innerHTML" ya que la cadena que devuelve JavaScript está en formato HTML (ej. <b>{Insert string here}</b> ).

Intenté configurar el texto interno de los elementos igual a su HTML interno, pero eso resultó en que cada cadena se mostrara como " <b>{Insert string here}</b> " en lugar de solo el texto en negrita.

Mi código:

 var text = document.getElementsByClassName('text-bold') var boldText = [] for (i = 0; i < text.length; i++) { // For all of the elements with the class "text": var str = text[i].innerText // Get the inner text var bold = str.bold() // Make the inner text bold boldText.push(bold) // Return the string to an array } for (i = 0; i < text.length; i++) { // For all of the elements with the class "text": text[i].innerHTML = boldText[i] // Replace the inner HTML with the corresponding bold text from the array }
 <div> <p class="text-bold">Hello!</p> <p class="text">Hi!</p> <p class="text-bold">Hey!</p> </div>

ACTUALIZAR:

Inicialmente pensé que esto era un problema con el móvil, pero parece que solo es un problema con Safari.

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!