最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JavaScript實(shí)現(xiàn)為input與textarea自定義hover,focus效果的方法

 更新時(shí)間:2015年08月21日 11:25:48   作者:企鵝  
這篇文章主要介紹了JavaScript實(shí)現(xiàn)為input與textarea自定義hover,focus效果的方法,可實(shí)現(xiàn)根據(jù)鼠標(biāo)事件動(dòng)態(tài)改變input與textarea樣式的功能,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了JavaScript實(shí)現(xiàn)為input與textarea自定義hover,focus效果的方法。分享給大家供大家參考。具體如下:

這里演示JavaScript為input輸入框和textarea文本框自定義hover,focus效果,hover也就是鼠標(biāo)放上去之后的效果,focus是鼠標(biāo)焦點(diǎn)問(wèn)題,要實(shí)現(xiàn) 這種效果,需要JS來(lái)配合,這個(gè)例子就是很不錯(cuò)的,它把網(wǎng)頁(yè)上輸入框和文本框都加入了鼠標(biāo)懸停和鼠標(biāo)焦點(diǎn)效果。

運(yùn)行效果截圖如下:

在線演示地址如下:

http://demo.jb51.net/js/2015/js-input-textarea-hover-focus-style-codes/

具體代碼如下:

<title>JavaScript為input/textarea自定義hover,focus效果</title>
<script type="text/javascript">
function suckerfish(type, tag, parentId) { 
if (window.attachEvent) { 
window.attachEvent("onload", function() { 
var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag); 
type(sfEls); 
}); 
} 
} 
sfHover = function(sfEls) { 
for (var i=0; i < sfEls.length; i++) { 
sfEls[i].onmouseover=function() { 
this.className+=" iptHover"; 
} 
sfEls[i].onmouseout=function() { 
this.className=this.className.replace(new RegExp(" iptHover\\b"), ""); 
} 
} 
} 
sfFocus = function(sfEls) { 
for (var i=0; i < sfEls.length; i++) { 
sfEls[i].onfocus=function() { 
this.className+=" iptFocus"; 
} 
sfEls[i].onblur=function() { 
this.className=this.className.replace(new RegExp(" iptFocus\\b"), ""); 
} 
} 
}
</script>
<style type="text/css">
textarea{
border:1px solid #BBE1F1;
width:250px;
height:80px;
}
 .iptHover,input:hover,textarea:hover{
border:1px solid #77C2E3;
}
.iptFocus,input:focus,textarea:focus{
border:1px solid #77C2E3;
background-color:#EFF7FF;
}
</style>
<input type="text" name="textfield" /><br />
<textarea name="textarea"></textarea>
<script type="text/javascript">
suckerfish(sfHover, "input");
suckerfish(sfFocus, "input");
suckerfish(sfHover, "textarea");
suckerfish(sfFocus, "textarea");
</script>

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

通州市| 铁岭市| 灵丘县| 津南区| 晋宁县| 集安市| 当涂县| 县级市| 衡东县| 泸水县| 苍南县| 荆州市| 嵩明县| 大埔县| 吴江市| 牙克石市| 卢湾区| 当雄县| 盐池县| 顺平县| 聂荣县| 汝城县| 钟山县| 海丰县| 潍坊市| 泽州县| 金沙县| 紫金县| 临沭县| 洛扎县| 德兴市| 太白县| 东山县| 临西县| 湘潭市| 绍兴县| 中卫市| 宜兴市| 湾仔区| 江油市| 溧水县|