文本框高亮显示

    <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 = ''
    }
}
posted @ 2021-03-20 18:01  yuanliy  阅读(52)  评论(0编辑  收藏  举报