国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

鼠標經過的文本框textbox變色

2024-05-06 14:15:22
字體:
來源:轉載
供稿:網友
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;
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 互助| 永康市| 台北县| 即墨市| 楚雄市| 尉犁县| 大悟县| 大理市| 喀喇沁旗| 忻州市| 尼玛县| 会同县| 凌云县| 大英县| 遂昌县| 青州市| 德清县| 子长县| 德兴市| 时尚| 蕲春县| 静安区| 株洲市| 元谋县| 吴忠市| 满洲里市| 平顶山市| 宣汉县| 广宁县| 龙陵县| 会东县| 泗水县| 五莲县| 德格县| 龙游县| 芒康县| 瓮安县| 高陵县| 兰州市| 南溪县| 宜丰县|