色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

鼠標經過的文本框textbox變色

JS文件:
復制代碼 代碼如下:
function mouseAction() {
var textInputs = document.getElementsByTagName("input");
var len = textInputs.length;
var index = 0;
var textInput;
/*
也能用 for in 語句遍歷
for (textInput in textInputs){
textInputs[textInput].onmouseover = functionName;
}
*/
for( index = 0; index < len; index++ ) {
textInput = textInputs[index];
if( textInput.getAttribute("type") == "text" ){
textInput.onmouseover = function (){
//也能用這種方式 this.style.backgroundColor = "red";
this.className = "txtMouseOver"; //要先在HTML中引入CSS文件
}; //注意要加分號

textInput.onmouseout = function(){
this.className = "txtMouseOut";
};

textInput.onfocus = function(){
this.className = "txtMouseFocus";
};

textInput.onblur = function(){
this.className = "txtMouseBlur";
};
}
}
}

//也可以直接跟一個函數名,不要加引號,括號 window.onload = mouseAction;
window.onload = function(){
mouseAction();
};

CSS文件:
復制代碼 代碼如下:
/*主體居中顯示*/
body{
    width: 80%;
    height: 800px;
    position: relative;
    margin-left: 10%;
    /*left: -40%;*/
    border: #00CCFF solid thin;
}
.txtMouseOver
{
border-color: #9ecc00;
}
.txtMouseOut
{
border-color: #84a1bd;
}
.txtMouseFocus
{
border-color: #9ecc00;
background-color: #e8f9ff;
}
.txtMouseBlur
{
border-color: #84a1bd;
background-color: #ffffff;
}

JavaScript技術鼠標經過的文本框textbox變色,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 叶城县| 岑溪市| 新安县| 星座| 东兰县| 芮城县| 峨眉山市| 项城市| 阜平县| 长白| 黑水县| 侯马市| 调兵山市| 包头市| 鞍山市| 曲水县| 崇文区| 阳曲县| 平阳县| 临澧县| 南雄市| 镇康县| 大宁县| 台南县| 普定县| 桂东县| 河东区| 万源市| 安仁县| 山阳县| 武胜县| 庆安县| 阳东县| 蓝田县| 屏东市| 闽清县| 黄冈市| 青神县| 潞西市| 西林县| 博兴县|