当前文本框高亮效果代码实例
分类:实例代码
当前文本框高亮效果代码实例属于前端实例代码,有关更多实例代码大家可以查看。
本章节分享一段代码实例,它实现了当前获取焦点的文本框高亮效果。
代码实例如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.pipipi.net/" /> <title>前端教程网</title> <style> div { width: 242px; height: 100px; border: 1px solid #171615; background-color: #FFC107; text-align: center; margin: 0 auto; line-height: 43px; } .add_class { border: 2px solid #5A4944; background-color: #E8E6D2; } </style> <script> window.onload = function () { var oInput = document.getElementsByTagName('input'); for (var index = 0; index < oInput.length; index++) { oInput[index].onfocus = function () { this.className = "add_class"; }; oInput[index].onblur = function () { this.className = ""; } } } </script> </head> <body> <div id="exdiv"> <label> <span>账号:</span> <input type="text"> </label> <label> <span>密码:</span> <input type="text"> </label> </div> </body> </html>
当前文本框高亮效果代码实例,这样的场景在实际项目中还是用的比较多的,关于当前文本框高亮效果代码实例就介绍到这了。