日期:2014-05-16 浏览次数:20416 次
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style> * { margin:0; padding:0; font-size:14px; } table { margin:100px; } td { width:200px; height:30px; line-height:30px; border:1px solid blue; } input { width:200px; height:30px; line-height:30px; border:0; } </style> </head> <body> <table> <tr> <td><input value="1-1" /></td> <td><input value="1-2" /></td> </tr> <tr> <td><input value="2-1" /></td> <td><input value="2-2" /></td> </tr> </table> <script> function $(el){ return typeof el == 'string' ? document.getElementById(el) : el; } function $t(name, cot){ cot = cot || document; return cot.getElementsByTagName(name); } var arr = $t('input'); for(var i = 0, len = arr.length; i < len; i++){ arr[i].onfocus = function(){ this.style.border = '1px solid red'; this.parentNode.style.border = '0'; } arr[i].onblur = function(){ this.style.border = 'none'; this.parentNode.style.border = '1px solid blue'; } } </script> </body> </html>