How do I insert text if a div exists?

First off, I’m fairly new to Javascript and I’m working on wordpress plugins so a huge apology if this seems a little vague… (I have decent knowledge of HTML/CSS so I’m getting there!)

I need to display the text “Starting” to appear before the date in “tribe-event-date-start” ONLY IF the class “tribe-event-date-end” exists.

For example:

<span class="tribe-event-date-start">3 June - 9:00 pm</span> - <span class="tribe-event-date-end">6 June - 9:00 pm</span>

I’ve done this already in HTML by editing the CSS like this:

.tribe-event-date-start:before {
    content: "Starting ";

…but this puts the text in front of ALL dates which isn’t ideal…

Is this something I can do in javascript?

Read more here: How do I insert text if a div exists?

Leave a Reply

Your email address will not be published. Required fields are marked *