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

145
Vistas
innerText and CSS content:before

I am trying to find out if content in a ::before selector changes the parent's innerText in any browser. I have tested in Chrome and Safari so far, and it doesn't change the innerText in either

document.querySelectorAll("li").forEach(function() {
  this.addEventListener("click", function(e) {
    e.target.classList.toggle("Completed");
  });
});

document.getElementById("test").addEventListener("click", function() {
  console.log(testUL.innerText);
});
    li.Completed:before {
      content: "\2713";
      color: green;
      background: #ffdf87;
    }
<ul id="testUL">
<li>a</li>
<li>b</li>
<li>c</li>
</ul>

<button id="test">Test innerText</button>

This is good for my purposes (I am trying to match documents by text only). But from what I read on Mozilla, it seems like maybe this is incorrect behavior?

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText

Can anyone test this snippet I've posted here and confirm if similar behavior occurs in MS Edge?

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

0

Yes same behaviour in MS Edge (Windows10).

This is as expected. The content of the pseudo element can be seen, but it not a 'proper' part of the page, hence the word 'pseudo'.

It is basically there for visual effect rather than 'real' content. For example, normally screen readers won't take any notice of it.

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