基于jquery點擊自以外任意處,關閉自身的代碼
更新時間:2012年02月10日 17:29:16 作者:
主要功能是點擊顯示,然后通過點擊頁面的任意位置都能關閉顯示效果,主要是$(document).click的作用
Html:
<div class="down">click</div>
<div class="con hide">show-area</div>
CSS:
.hide{display:none;}
js:
$(document).ready(function(){
$("div.down").click(function(e){
e.stopPropagation();
$("div.con").removeClass("hide");
});
$(document).click(function(){
if(!$("div.con").hasClass("hide")){
$("div.con").addClass("hide");
}
});
});
復制代碼 代碼如下:
<div class="down">click</div>
<div class="con hide">show-area</div>
CSS:
復制代碼 代碼如下:
.hide{display:none;}
js:
復制代碼 代碼如下:
$(document).ready(function(){
$("div.down").click(function(e){
e.stopPropagation();
$("div.con").removeClass("hide");
});
$(document).click(function(){
if(!$("div.con").hasClass("hide")){
$("div.con").addClass("hide");
}
});
});
相關文章
基于jquery的從一個頁面跳轉到另一個頁面的指定位置的實現(xiàn)代碼(帶平滑移動的效果)
從一個頁面跳轉到另一個頁面的指定位置 如果不帶平滑移動的效果 很容易 加個 錨點就行了2011-05-05
通過jquery.cookie.js實現(xiàn)記住用戶名、密碼登錄功能
這篇文章主要介紹了通過jquery.cookie.js實現(xiàn)記住用戶名、密碼登錄功能,通過Cookies讓網站服務器把少量數(shù)據(jù)儲存到客戶端的硬盤或內存,從客戶端的硬盤讀取數(shù)據(jù)的一種技術;具體實現(xiàn)過程大家通過本文一起看看吧2018-06-06
jQuery實現(xiàn)的指紋掃描效果實例(附演示與demo源碼下載)
這篇文章主要介紹了jQuery實現(xiàn)的指紋掃描效果,以完整實例形式分析了jQuery實現(xiàn)圖像按照指定模式顯示的相關實現(xiàn)技巧,并附帶附示例演示與demo源碼供讀者下載參考,需要的朋友可以參考下2016-01-01

