JQuery – Snippet in WP 6.1.1
-
Hello dear wordpress cracks,
I want to add a css class to a span element, that has certain content.
There are 3 stati where I want to add classes:<span class="statusfield">Done</span> <span class="statusfield">In Progress</span> <span class="statusfield">Pending</span>
Based on the content of the span element, a certain class should be added to the element.
I have now tried the following code using the plugin header “Footer Code Manager Pro”:<script> var status = { "Done": "done", "In Progess": "in-progress", "Pending": "pending" } $(".statusfield").each(function() { $(this).addClass(status[$(this).html()]); }); </script>
Unfortunately the code does not work. I have tried everything. Include in the header and in the footer with “document ready” and without.
Slowly I am a little desperate.Does anyone of you have a tip how I can solve this?
That would be great!
Have many thanks in advance!greetings
Bernd
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘JQuery – Snippet in WP 6.1.1’ is closed to new replies.