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

177
Vistas
How to add background color to the test in webpage?

I found some text in webpage using below code

document.body.innerText.indexOf('tested')
document.body.innerText.includes('tested')

after finding the text I want to apply background color to that text.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Find the reference of the element with your innerText:

let xpath = "//div[text()='tested']";
let element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

Replace div with whatever type of element you have where the text is present

You can directly change the style once you have the element reference:

element.style.backgroundColor = "red";

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