用jQuery语法回显html和PHP

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>

You can save it inside a variable like

var script = "<?php bloginfo('template_directory'); ?>" + "/js/carousel.js";

Watch out for the quote you use.

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

Note: It will work only if you write this code inside a php file

May be this is what u want

<script src="<?php echo bloginfo('template_directory'); ?>/js/carousel.js"></script>