当前位置: 移动技术网 > IT编程>开发语言>JavaScript > 输入框点击时边框变色效果的实现方法

输入框点击时边框变色效果的实现方法

2019年04月03日  | 移动技术网IT编程  | 我要评论

实例如下:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="textml; charset=utf-8" />
<title>输入框点击时边框变色效果</title>
</head>
<body>
<style type="text/css">
.focusinput {border:1px solid #99cc33;}
</style>
<script type="text/javascript"> 
function focusinput(focusclass) {
  var elements = document.getelementsbytagname("input");
  for (var i=0; i < elements.length; i++) {
    if (elements[i].type != "button" && elements[i].type != "submit" && elements[i].type != "reset") {
      elements[i].onfocus = function() { this.classname = focusclass; };
      elements[i].onblur = function() { this.classname = ''; };
    }
  }
}
window.onload = function () {
  focusinput('focusinput');
}
</script>
请输入姓名:<input type="text" />
</body>
</html>

以上就是小编为大家带来的输入框点击时边框变色效果的实现方法全部内容了,希望大家多多支持移动技术网~

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网