云上快速入门,热门云上应用快速查找
丰富的线上&线下活动,深入探索云世界
做任务,得社区积分和周边
最真实的开发者用云体验
让每位学生受益于普惠算力
让创作激发创新
资深技术专家手把手带教
遇见技术追梦人
畅聊无限,分享你的技术见解
技术交流,直击现场
海量开发者使用工具、手册,免费下载
极速、全面、稳定、安全的开源镜像
开发手册、白皮书、案例集等实战精华
为开发者定制的Chrome浏览器插件
热门
效果如图:
实现代码:
<style> table.formdata/*表格样式*/ { border:1px solid #5F6F7E; border-collapse:collapse;/*表格相邻边被合并 */ font-family:微软雅黑; font-size:10px; padding:2px; } </style> <script type="text/javascript"> function hilite(obj) { //选择包含<input>的<td>标记 obj = document.getElementById("td"+obj.id.toString()); obj.style.border = '2px solid #007EFF'; //加粗、变色 } function delite(obj) { obj = document.getElementById("td"+obj.id.toString()); obj.style.border = '0px solid #ABABAB'; //恢复回原来的边框 } </script> <table class="formdata"> <tr> <th></th> <th>2004</th> <th>2005</th> <th>2006</th> </tr> <tr> <tr><!--onFocus聚焦时,onBlur当光标离开时的事件;注意:td单元格的id比文本框的id多一个“td”,正是这样才能选择到包含<input>的<td>标记--> <th style="width:50px;">张三</th> <td id="tdzhangsan2004"><input type="text" id="zhangsan2004" onFocus="hilite(this);" onBlur="delite(this);"></td> <td id="tdzhangsan2005"><input type="text" id="zhangsan2005" onFocus="hilite(this);" onBlur="delite(this);"></td> <td id="tdzhangsan2006"><input type="text" id="zhangsan2006" onFocus="hilite(this);" onBlur="delite(this);"></td> </tr> <tr> <th>李四</th> <td id="tdlisi2004"><input type="text" id="lisi2004" onFocus="hilite(this);" onBlur="delite(this);"></td> <td id="tdlisi2005"><input type="text" id="lisi2005" onFocus="hilite(this);" onBlur="delite(this);"></td> <td id="tdlisi2006"><input type="text" id="lisi2006" onFocus="hilite(this);" onBlur="delite(this);"></td> </tr> <tr> <th>王五</th> <td id="tdwangwu2004"><input type="text" id="wangwu2004" onFocus="hilite(this);" onBlur="delite(this);"></td> <td id="tdwangwu2005"><input type="text" id="wangwu2005" onFocus="hilite(this);" onBlur="delite(this);"></td> <td id="tdwangwu2006"><input type="text" id="wangwu2006" onFocus="hilite(this);" onBlur="delite(this);"></td> </tr> </table>