首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

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

2012-05-20 
这段定义字符串变量代码错哪里?var tt table width200 border0 height65trth height33

这段定义字符串变量代码错哪里?
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>';



热点排行