Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
How do i echo the following HTML and PHP in jQuery to make it render as html?
<script src="<?php bloginfo('template_directory'); ?>/js/carousel.js"></script>
<?php bloginfo('template_directory'); ?>
var dir = '<?php bloginfo('template_directory'); ?>';
<script src="'+var+'/js/carousel.js"></script>
.html
<script>
You can save it inside a variable like
var script = "<?php bloginfo('template_directory'); ?>" + "/js/carousel.js";
Watch out for the quote you use.
Add a comment
Try the below code.
$('head').append('<script src="<?php bloginfo('template_directory'); ?>/js/carousel.js"></script>')
It will add the code at the end of head tag. Assuming all your jquery library available in head tag
head
jquery
Note: It will work only if you write this code inside a php file
php
May be this is what u want
<script src="<?php echo bloginfo('template_directory'); ?>/js/carousel.js"></script>
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
<?php bloginfo('template_directory'); ?>in a variable, like:var dir = '<?php bloginfo('template_directory'); ?>';then use it in the script src. like:<script src="'+var+'/js/carousel.js"></script>.htmlinside another<script>tag