標籤:style blog io ar color os sp on div
這段時間一直在做移動端的網站,順便寫一點總結吧,隨便寫的,想到什麼寫什麼,所有若有幸被各位所看到,可以無視哈。。。。
1.
1 $(document).bind("click",function(e){ 2 var target = $(e.target); 3 if(target.closest(".pop").length == 0){ 4 $(".pop").hide(); 5 } 6 })
這段代碼,是在做右上方菜單時候用到的, 意思是除了“.pop”元素塊之外的文檔任何地方點擊一下“.pop”隱藏掉、、、
1 target.closest(".pop").length == 0
這段代碼可以說是這個小功能的中最難懂的一段代碼,target 是目標對象,詳細解釋:
e.target的含義$(function(){ $("li:has(ul)").click(function(e){ if(this==e.target){ $(this).children().toggle(); $(this).css("list-style-image",($(this).children().is(":hidden")?"url(plus.gif)":"url(minus.gif)")) } return false; //避免不必要的事件混繞 }).css("cursor","pointer").click(); //載入時觸發點擊事件 //對於沒有子項的菜單,統一設定 $("li:not(:has(ul))").css({ "cursor":"default", "list-style-image":"none" });});===========================具體問題具體分析;當前目標在event事件中代表點擊對象;loader事件:載入對象;e只是參數,任意取值;對應即可;e.target 是目標對象,e.event是目標所發生的事件。
2.文字溢出部分隱藏並添加省略符號: overflow:hidden;white-space: nowrap;text-overflow: ellipsis;
移動端網站開發總結2