我想要在字符串中顯示一些vars的值。Javascript在代碼中顯示var
function test()
{
var first = document.getElementById('first').value; //value ==hello
var second = document.getElementById("second").value; //value == bye
var third = document.getElementById("third").value; //value == crazy
var forth = document.getElementById("forth").value; // value == night
var myString = " \
<script> \
var firstValue = "\" + first + \""; \
var secondValue = "\" + second + \""; \
var thirdValue = "\" +third + \""; \
var forthValue = "\" +forth + \""; \
<\/script> ";
我希望字符串顯示:
<script>
var firstValue = " hello ";
var secondValue = " bye ";
var thirdValue = " crazy ";
var forthValue = " night ";
</script> ";
你的問題不清楚。你想要做什麼?你爲什麼需要這樣做? – elclanrs
您的問題存在多個問題,導致回答者不得不猜測如何幫助您。您能否與我們分享一個沒有任何語法錯誤的程序,或許以[最小完整有效示例](http://stackoverflow.com/help/mcve)的形式 –
我已更新該問題,謝謝 – R00059159