简体   繁体   中英

How to insert HTML markup with PHP content in JS

我的意思是在 HTML 中,当我尝试将这样的字符串添加到 js $('.msg_content').append('<span><?php echo $item; ?></span>');时,这不起作用$('.msg_content').append('<span><?php echo $item; ?></span>');

Probably would be best to rename your .html page into a .php page. This would resolve your issue I think.

Also side note you can use

<?= $item; ?> instead of <?php echo $item; ?>

Provide some additional information for additional help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM