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

260
Vistas
Set Property Value of Pseudo-Elements Using JavaScript

I have this form, and I want to change the display property of the pseudo-element ::after of the form's child elements.

This is the line I am using to modify the value:

window.getComputedStyle(document.querySelector('.lf-u-container'), '::before').setProperty('display', 'inline');

HTML for form

<form class="loginForm hidden" id="loginForm">
    <div class="lf-heading">Enter Login Credentials <span><u>Create An Account Instead?</u></span></div>
    <div class="lf-container lf-u-container"><input class="lb-username" id="lf-username" name="username" type="text" placeholder="Enter Username"></div>
    <div class="lf-container lf-p-container"><input class="lb-password" id="lf-password" name="password" type="password" placeholder="Enter Password"></div>
    <div class="input-group">
            <label for="lb-StaySignedIn">Stay Signed In?</label>
            <input class="lb-StaySignedIn" type="checkbox">
            <button type="submit" id="loginSubmit"></button>
    </div>
</form>

The problem is that I get an error message saying that

Uncaught DOMException: Failed to execute 'setProperty' on 'CSSStyleDeclaration': These styles are computed, and therefore the 'display' property is read-only.

So, I would like to know how can I modify the property value of pseudo-elements using JavaScript. There are existing solutions with JQuery, but I am using JavaScript only for my project.

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