bloginfo url in javascript

by Omer Gilboa   Last Updated October 19, 2019 20:08 PM

I'm trying to set <?php bloginfo('template_url'); ?> in a variable on Javascript, and then to set src of an img element, but in the html it's been printed as src="<?php bloginfo('template_url'); ?>" and not as the actually url.

This is how I tried to do it:

var wpTemplateUrl = "<?php bloginfo('template_url'); ?>"; primaryImg.src = wpTemplateUrl;



Related Questions


Updated April 10, 2015 22:03 PM

Updated July 30, 2017 23:08 PM

Updated August 02, 2017 18:08 PM

Updated February 19, 2017 09:08 AM

Updated August 23, 2019 15:08 PM