我試圖通過PHP echo
從MySQL接收的數據定義一個值。如何將PHP代碼放入JavaScript?
如何把PHP echo
的代碼導入JavaScript?
例子:
document.addEventListener("DOMContentLoaded", function(event) {
var gg1 = new JustGage({
id: "gg1",
value: <?php echo 'Hello World!' ?>
min: 0,
max: 100,
title: "Target",
可能的重複[如何嵌入p惠普在JavaScript?](http://stackoverflow.com/questions/3352576/how-to-embed-php-in-javascript) – Marcin
它會工作! youre just missing **,** behind your value data ... –
試試這個, value:'<?php echo'Hello World!' ?'', – manian