如何获得文本框的属性值,急!!!

stephenyk 2007-09-07 10:57:50
<link rel="stylesheet" href="test.css">

<style type="text/css">
.test {
height: auto;
width: auto;
border: 1px solid #0099FF;
background-color: #99FF00;
margin: 0px;
padding: 0px;
}

</style>
<form name="form1" action=test.asp method="post">
<table border=1>
<tr>
<td>
input type=text name=number class="test" onfocus="this.style.backgroundColor='#99FF00';alert(this.style.backgroundColor);">
</td>
</tr>
</table>

如果焦点在文本框上,弹出框显示“#99FF00”,但是如果onfocus变为“alert(this.style.backgroundColor);",而弹出框显示空。为什么啊?
...全文
169 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hij333 2007-09-07
  • 打赏
  • 举报
回复
没有.不好意思
stephenyk 2007-09-07
  • 打赏
  • 举报
回复
成功!!!谢谢!!!请教楼上有没有详细的html属性参考资料??
hij333 2007-09-07
  • 打赏
  • 举报
回复
style和元素写在一起的可以用style直接获取属性.
样式表单提出来的,IE下用currentStyle来获取,更改的时候还用style.
hij333 2007-09-07
  • 打赏
  • 举报
回复
alert(this.currentStyle.backgroundColor);"

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧