Replacing String Within WordPress

I’m having a little trouble replacing a string of code within a WP template with the use of this:

$("document").ready(function () {
var newH = $("<h1>");
newH.append("<h1>Covered California — Outreach, Education & Enrollment</h1>");
$("h1").html(<h1>Covered California — Outreach,<br />Education & Enrollment</h1>");
});

Basically I need to add a
within a string. I’m not receiving any results. Where am I going wrong with this?

Did you test to make sure Javascript and Jquery work in your template? Sometimes there is an issue with not enqueuing the scripts properly in WordPress.

Yes, jQuery is loading on the site just fine with elements using jQuery. I’m wondering if it’s in my way of using the above code.

First, you’re missing a ". It should be

$("h1").html("<h1

Does the string already exist somewhere on the page? You really should be fixing this through WordPress/PHP, but if you can’t for some reason the following will work:

$("document").ready(function(){
    $("h1").html("Covered California - Outreach, <br> Education & Enrollment")
})

I actually did just that, OxRamos, and everything works great!

Thank you.

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