您现在的位置是:首页 > 电脑技术查询 > web开发

[10分] 当焦点在一个文本框上时执行事件解决思路

编辑:chaxungu时间:2022-10-02 23:20:00分类:web开发

[10分] 当焦点在一个文本框上时执行事件
我想实现这个:

当焦点在一个文本框上时,更改一个表格的背景颜色,请问这个 js 该怎么写?

文本框:
<input name= "ctl00$cphMain$txbCreditCardNo " type= "text " maxlength= "16 " id= "ctl00_cphMain_txbCreditCardNo " style= "font-family:Arial;font-size:9pt;width:125px; " />

表格:
<table id= "ctl00_cphMain_tblCreditCardNo " border= "0 " cellpadding= "2 " cellspacing= "0 " style= "width: 100% ">

谢谢各位

------解决方案--------------------

<form>
<table width= "200 " border= "1 " id= "ctl00_cphMain_tblCreditCardNo ">
<tr>
<td> &nbsp; </td>
<td> &nbsp; </td>
<td> &nbsp; </td>
</tr>
<tr>
<td> &nbsp; </td>
<td> &nbsp; </td>
<td> &nbsp; </td>
</tr>
<tr>
<td> &nbsp; </td>
<td> &nbsp; </td>
<td> &nbsp; </td>
</tr>
</table>
</form>

<input name= "ctl00$cphMain$txbCreditCardNo "
type= "text " maxlength= "16 "
id= "ctl00_cphMain_txbCreditCardNo "
onfocus= "document.getElementById( 'ctl00_cphMain_tblCreditCardNo ').bgColor= '#FF00000 '; "
style= "font-family:Arial;font-size:9pt;width:125px; " />


给分吧

------解决方案--------------------
离开焦点用 onblur