Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
How do I change all references to a string in a class with css in javascript?

Hello I am trying to target all references to the phrase "Elementor" in each item that has the "post-state" class and then apply css changes to just those. I am not too savvy with JQuery or Javascript so any guidance would be greatly appreciated. This is the code I have concocted. It does not seem to be working.

var elementor = document.getElementsByClassName("post-state");

if($('elementor:contains("Elementor")')){
    elementor.style.color = 'red !important';
    elementor.style.fontWeight = 'bold !important';
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Something like, should work:

// Target all the elements with 'post-state' css class containing "Elementor" string
$('.post-state:contains("Elementor")').each(function () {
  $(this).css("color", 'red !important');
  $(this).css("fontWeight", 'bold !important');
});

The selector $('.post-state:contains("Elementor")') will select all the elements with class post-state that contain the text string Elementor.

.each() will iterate all the elements in the selector and loop over each, with this as a reference to the individual element.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda