Javascript显示字符串中var的值?

时间:2014-01-18 03:06:10

标签: javascript html

我希望某些变量的值显示在字符串中。

 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> ";

0 个答案:

没有答案