jQuery only working with a hard refresh

Hi there,

I have the following jQuery which only seems to work when I do a hard refresh on a page.

$(document).ready(function() {
jQuery('.single-listing-description .job_description h3:contains("Free")').html(function() {
    return $(this).html().replace('Free', '<span class="free-tag">Free</span>');

jQuery('.single-listing-description .job_description h3:contains("Win")').html(function() {
    return $(this).html().replace('Win', '<span class="win-tag">Win</span>');

I’ve tried wrapping it in a document ready function, but it still requires a hard refresh.

Can anyone suggest a reason why this would be?

I am basically trying to wrap two words in a H3 title in a tag which the above jQuery does, but could this be done is CSS? I couldn’t seem to find something that does similar to :contains in jQuery in CSS.


When do you expect your code to do something other than when it loads the page?

The page loads fully, but it doesn’t update my code as I want it to, i.e. adding the class to a H3 tag. It only updates when I do a hard refresh

Is your javascript in an external file?

When you are developing a page and making regular changes, it can help to open up the developer tools and disable the cache in the network panel.

Thank you for suggesting that, I will give that a go. I can see in console that I don’t have any errors in the JS so guessing it may just be a caching issue.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.