淺析PHP7新功能及語法變化總結
776
2024-01-31
jquery實現點擊鏈接彈出層效果:本例實現的主要原理:jquery操作DOM元素。對層樣式的設置。將display:設置為none;讓層隱藏;
代碼實例如下:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.gimoo.net" /> <title>子選擇器</title> <style type="text/css"> #choice_list_district{ height:50px; } #tab td{ cursor:pointer; } #divobj{ position:absolute; width:200px; height:200px; background:blue; border:1px solid block; display:none; z-index:9999; } </style> <script type="text/javascript" src="http://www.gimoo.net/t/1904/mytest/jQuery/jquery-1.8.3.js"></script> <script type="text/javascript"> $(function (){ $("#choice_list_district a").click(function(e){ if($("#divobj").css("display")=="none"){ e.stopPropagation(); var offset=$(e.target).offset(); $("#divobj").css({top:offset.top+$(e.target).height()+"px",left:offset.left}); $("#divobj").show(); } else{ $("#divobj").hide(); } }); $(document).click(function(event){ $("#divobj").hide(); }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div id="choice_list_district"> <a >出來層</a> </div> <div id="divobj"></div> </div> </form> </body> </html>
以上代碼中,點擊鏈接可以彈出隱藏的層,再點擊任何地方就可以隱藏此層。
本段代碼簡單易懂,寫的不好還請各位大俠見諒,希望本文分享能夠給大家帶來幫助。
#免責聲明#
本站[綠夏技術導航]提供的一切軟件、教程和內容信息僅限用于學習和研究目的;不得將上述內容用于商業或者非法用途,否則,一切后果請用戶自負。本站信息來自網絡收集整理,版權爭議與本站無關。您必須在下載后的24個小時之內,從您的電腦或手機中徹底刪除上述內容。如果您喜歡該程序或內容,請支持正版,購買注冊,得到更好的正版服務。我們非常重視版權問題,如有侵權請郵件[admin@lxwl520.com]與我們聯系進行刪除處理。敬請諒解!