文本框高亮显示

    <style>
        input{
            display: block;
        }
    </style>
<body>
    <ul><input type="text"><input type="text"><input type="text"><input type="text"></ul>
</body>
var inpArr = document.getElementsByTagName('input')
for(var i = 0;i < inpArr.length;i++){
    inpArr[i].onfocus = function(){
        this.style.border = '2px solid #008c8c'
        this.style.backgroundColor = '#ccc'
    }
    inpArr[i].onblur = function(){
        this.style.border = ''
        this.style.backgroundColor = ''
    }
}
原文地址:https://www.cnblogs.com/yuanliy/p/14561344.html