I am currently building a WordPress theme where I am using jQuery to append and prepend some ornate images to a h4 tag with a class of beechheader in the page template markup.
Before turning the static html files into a WordPress theme, the code below worked great. The code is in a separate file called test.js
The jQuery code appears to be enqueued correctly in the functions file and I have called the test.js code using
<script src="<?php bloginfo('template_directory'); ?>/javascripts/whatever.js"></script>
right before the closing body tag. Here is the code that worked fine statically but now doesnt work
// prepend some images to the headers
$(function() {
$("h4.beechheader")
.prepend('<img src="/images/beechleft.gif" alt="" />')
.append('<img src="/images/beechright.gif" alt="" />');
});
I tried adding
<?php echo get_template_directory_uri(); ?>
before the trailing slash before images as you would in the html file. My research leads me to believe jQuery files may need to be handled a bit differently but I am unsure of the syntax or what to do. Can anyone help?