I’m trying to combine the location of my WordPress theme folder to a jQuery element. I haven’t used jQuery much before and I’ve done a little research but haven’t found anything of value.
Here’s my JavaScript variable
<script type="text/javascript">var templateDir = "<?php bloginfo('template_directory') ?>";
And I’m wanting to add ‘templateDir’ to this:
$next = $('<li><a href="#" class="next" class="controls"><img src="images/right_button.png" border="0" /></a></li>');
Ideally I thought it would be something like this, but it just errors.
$next = $('<li><a href="#" class="next" class="controls"><img src="' + templateDir + 'images/right_button.png" border="0" /></a></li>');
So I’m not quite sure how it works. Thanks.
Update: Fixed the issue. Seems it was all down to the jQuery file not being first. Thanks.
Try
That is, using a single ‘class’ attribute. Maybe that is what is causing error
UPDATE:
Make sure you have jquery library file included at the beginning before calling the reference functions.