Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!