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

125
Vistas
how to remove a content of (::before) or just hide the before content

in my case i want to delete the content of (::before) or hide it in jquery/javacript

Can anyone help please ?

I have trying this but it's not working

$(".element").attr('data-before','');
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can't directly target ::before with jQuery or inline styling, only with CSS.

You could add a class to the element with a CSS rule that hides its ::before content when it has that class:

.element.hide-before::before {
    display: none;
}
$(".element").addClass("hide-before");

Live Example:

setInterval(() => {
    $(".element").toggleClass("hide-before");
}, 1000);
.element::before {
    content: "::before content";
    border: 1px solid grey;
}
.element.hide-before::before {
    display: none;
}
<div class="element"> inline content</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

If you wanted to be able to control the content via JavaScript code, you could make the content come from an attribute (Like your data-before):

.element::before {
    content: attr(data-before);
}

Then you could "remove" it by making it blank:

$(".element").attr("data-before", "");

but you could also change it to something else by providing a non-empty string.

Live Example:

let counter = 0;
setInterval(() => {
    ++counter;
    $(".element").attr("data-before", counter === 4 ? "" : `before ${counter}`);
    if (counter === 4) {
        counter = -1;
    }
}, 1000);
.element::before {
    content: attr(data-before);
    border: 1px solid grey;
}
<div class="element" data-before="before 0"> inline</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

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