读书人

这段定义字符串变量代码错哪里?解决办

发布时间: 2012-05-20 16:03:12 作者: rapoo

这段定义字符串变量代码错哪里?
var tt = "<table width="200" border="0" height="65">
<tr>
<th height="33" colspan="2" scope="row">查找</th>
</tr>
<tr>
<th width="110" scope="row"><input type="text" /></th>
<th width="74" height="33"scope="row"><input type="button" value="确定" size="20" /></th>
</tr>
</table>";

这段定义字符串变量代码错哪里?





[解决办法]
双引号里套双引号,里面的双引号 需要 转义


这里可以 用单引号

JScript code
var tt = '<table width="200" border="0" height="65"><tr><th height="33" colspan="2" scope="row">查找</th></tr><tr><th width="110" scope="row"><input type="text" /></th><th width="74" height="33"scope="row"><input type="button" value="确定" size="20" /></th></tr></table>';
[解决办法]
var tt = "<table width='200' border='0' height='65'>
<tr>
<th height='33' colspan='2' scope='row'>查找</th>
</tr>
<tr>
<th width='110' scope='row'><input type='text' /></th>
<th width='74' height='33' scope='row'><input type='button' value='确定' size='20' /></th>
</tr>
</table>";或者
var tt = '<table width="200" border="0" height="65">
<tr>
<th height="33" colspan="2" scope="row">查找</th>
</tr>
<tr>
<th width="110" scope="row"><input type="text" /></th>
<th width="74" height="33"scope="row"><input type="button" value="确定" size="20" /></th>
</tr>
</table>';



读书人网 >JavaScript

热点推荐