HTML title属性问题: title=变量, 为什么显示的是变量的名字
代码如下:varUNIT=8190;vartitle_unit="[1,"+UNIT+"]";BODY的代码:<tr><td></td><td></td><tdvalig...
代码如下:
var UNIT = 8190;
var title_unit = "[1,"+UNIT+"]";
BODY的代码:
<tr>
<td></td>
<td></td>
<td valign=top nowrap><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Unit:</font></td>
<td colspan="2" valign=top nowrap><div align="right" title=title_unit>
<input id="apart" type="text" size="8" maxlength="4"></div>
</td>
<td></td>
</tr>
我希望提示的是[1,8190],但不想在input里直接写title=[1,8190],该怎么办? 展开
var UNIT = 8190;
var title_unit = "[1,"+UNIT+"]";
BODY的代码:
<tr>
<td></td>
<td></td>
<td valign=top nowrap><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Unit:</font></td>
<td colspan="2" valign=top nowrap><div align="right" title=title_unit>
<input id="apart" type="text" size="8" maxlength="4"></div>
</td>
<td></td>
</tr>
我希望提示的是[1,8190],但不想在input里直接写title=[1,8190],该怎么办? 展开
展开全部
试试这样,也就是说在页面加载完以后,用JS设置title属性的值
<script type="text/javascript">
var UNIT = 8190;
var title_unit = "[1,"+UNIT+"]";
</script>
<table>
<tr>
<td></td>
<td></td>
<td valign=top nowrap><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Unit:</font></td>
<td colspan="2" valign=top nowrap>
<div align="right" id="title_uint"><input id="apart" type="text" size="8" maxlength="4"></div>
</td>
<td></td>
</tr>
</table>
<script type="text/javascript">
document.getElementById("title_uint").title = title_unit;
</script>
<script type="text/javascript">
var UNIT = 8190;
var title_unit = "[1,"+UNIT+"]";
</script>
<table>
<tr>
<td></td>
<td></td>
<td valign=top nowrap><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Unit:</font></td>
<td colspan="2" valign=top nowrap>
<div align="right" id="title_uint"><input id="apart" type="text" size="8" maxlength="4"></div>
</td>
<td></td>
</tr>
</table>
<script type="text/javascript">
document.getElementById("title_uint").title = title_unit;
</script>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询