您好,登錄后才能下訂單哦!
這篇文章主要講解了“jQuery怎么實現模擬12306城市選擇框功能”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“jQuery怎么實現模擬12306城市選擇框功能”吧!
具體如下:
<!DOCTYPE html> <html> <head> <title>www.jb51.net jQuery城市選擇框</title> <style> #parent{ width:500px; position:relative; } #text{ height:25px; } #select{ width:420px; height:185px; position:absolute; top:31px; left:0; background:#eeeeee; } .cities{ width:60px; height:25px; line-height:25px; margin:5px 5px 0 5px; float:left; text-align:center; font-family:'Times New Roman'; font-size:15px; cursor:pointer; } </style> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("#select").hide(); $("#text").focus(function(){ $("#select").show(); }); $(".cities").click(function(){ $("#text").val($(this).text()); $("#select").hide(); }); $("#text").blur(function(){ setTimeout(function(){ $("#select").hide(); }, 300); }); }); </script> </head> <body> <div id="parent"> <input type="text" id="text"> <div id="select"> <div class="cities">烏魯木齊</div> <div class="cities">蘭州</div> <div class="cities">西寧</div> <div class="cities">拉薩</div> <div class="cities">呼和浩特</div> <div class="cities">哈爾濱</div> <div class="cities">長春</div> <div class="cities">沈陽</div> <div class="cities">三亞</div> <div class="cities">北京</div> <div class="cities">天津</div> <div class="cities">太原</div> <div class="cities">濟南</div> <div class="cities">銀川</div> <div class="cities">西安</div> <div class="cities">鄭州</div> <div class="cities">南京</div> <div class="cities">杭州</div> <div class="cities">福州</div> <div class="cities">廣州</div> <div class="cities">臺北</div> <div class="cities">南寧</div> <div class="cities">昆明</div> <div class="cities">成都</div> <div class="cities">重慶</div> <div class="cities">貴陽</div> <div class="cities">長沙</div> <div class="cities">南昌</div> <div class="cities">合肥</div> <div class="cities">武漢</div> <div class="cities">上海</div> <div class="cities">海口</div> <div class="cities">香港</div> <div class="cities">澳門</div> </div> </div> </body> </html>
運行效果如下:
感謝各位的閱讀,以上就是“jQuery怎么實現模擬12306城市選擇框功能”的內容了,經過本文的學習后,相信大家對jQuery怎么實現模擬12306城市選擇框功能這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。