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';
}
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.