日期:2014-05-16  浏览次数:20334 次

[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