I have a strange issue, I'm using jQuery to append some HTML to an h1 tag. I'm using a CMS here at work that I don't have access to the backend, so I have to do some trickery to make things work. My code I'm using is...
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var html = '<span style = "font-size: 10pt; font-style: italic; display: block;">Tools to help make your farm profitable and successful</span>';
$('.mainContent h1').first().html(html); });
</script>
Now I've tested this script on jsfiddle and it works just fine, it appends to the H1 tag and everything looks proper. When the actual page loads it, however, it's treating the entire html variable as a string and it's actually printing out the HTML (tags and all) instead of rendering it as you'd expect.
You can see what I mean here
I've attempted many different variations of it, but still can't seem to get it to work on the page. Any ideas? Thank you in advance.
append()in your sample code here, either. But yes, I'd imagine that wherever you're entering this script, at least the<chars are being converted to entities.<script type="text/javascript">// $(function() { var html = '<span style = "font-size: 10pt; font-style: italic; display: block;">Tools to help make your farm profitable and successful</span>'; $('.mainContent h1').first().append(html); });<span style = "font-size: 10pt; font-style: italic; display: block;">Tools to help make your farm profitable and successful</span>