javascript 輸入框提示列表效果_表單特效

來源:互聯網
上載者:User
代碼可以更簡潔些,有更簡便的方法歡迎貢獻出來啊。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>輸入框提示列表效果_雲棲社區</title> <style type="text/css"> <!-- body{background:#fff} .Menu { position:relative; width:204px; height:127px; z-index:1; background: #FFF; border:1px solid #000; margin-top:-100px; display:none; } .Menu2 { position: absolute; left:0; top:0; width:100%; height:auto; overflow:hidden; z-index:1; } .Menu2 ul{margin:0;padding:0} .Menu2 ul li{width:100%;height:25px;line-height:25px;text-indent:15px; border-bottom:1px dashed #ccc;color:#666;cursor:pointer; change:expression( this.onmouseover=function(){ this.style.background="#F2F5EF"; }, this.onmouseout=function(){ this.style.background=""; } ) } input{width:200px} .form{width:200px;height:auto;} .form div{position:relative;top:0;left:0;margin-bottom:5px} #List1,#List2,#List3{left:0px;top:93px;} --> </style> <script type="text/javascript"> function showAndHide(obj,types){ var Layer=window.document.getElementById(obj); switch(types){ case "show": Layer.style.display="block"; break; case "hide": Layer.style.display="none"; } } function getValue(obj,str){ var input=window.document.getElementById(obj); input.value=str; } </script> </head> <body> <div class="form"> <div> Location:<input type="text" id="txt" name="txt" onClick="showAndHide('List1','show');" onblur="showAndHide('List1','hide');"></div> <!--列表1--> <div class="Menu" id="List1"> <div class="Menu2"> <ul> <li onmousedown="getValue('txt','中國CHINA');showAndHide('List1','hide');">中國CHINA</li> <li onmousedown="getValue('txt','美國USA');showAndHide('List1','hide');">美國USA</li> </ul> </div> </div> <div> Sex:<input type="text" id="txt2" name="txt2" onClick="showAndHide('List2','show');" onblur="showAndHide('List2','hide');"></div> <!--列表2--> <div class="Menu" id="List2"> <div class="Menu2"> <ul> <li onmousedown="getValue('txt2','男Male');showAndHide('List2','hide');">男Male</li> <li onmousedown="getValue('txt2','女Female');showAndHide('List2','hide');">女Female</li> </ul> </div> </div> <div> education:<input type="text" id="txt3" name="txt3" onClick="showAndHide('List3','show');" onblur="showAndHide('List3','hide');"></div> <!--列表3--> <div class="Menu" id="List3"> <div class="Menu2"> <ul> <li onmousedown="getValue('txt3','大專');showAndHide('List3','hide');">大專</li> <li onmousedown="getValue('txt3','本科');showAndHide('List3','hide');">本科</li> <li onmousedown="getValue('txt3','碩士');showAndHide('List3','hide');">碩士</li> <li onmousedown="getValue('txt3','本科');showAndHide('List3','hide');">本科</li> </ul> </div> </div> </div> </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.