开发者

Autohide div onclick

开发者 https://www.devze.com 2023-03-24 01:22 出处:网络
Hello I was looking for a script to show/hide a div and I found this one which I tweaked a little bit but works perfectly.

Hello I was looking for a script to show/hide a div and I found this one which I tweaked a little bit but works perfectly.

$(function() {
$(".activities a").click(function(e) {
    $('.search').html('<center><img src="images/loading.gif" style="margin: 20px 0;" /></center>');
    $(".search").toggle().toggleClass("active");
    $('.search').load('someurlhere.php');
    e.stopPropagation();
});


$(document).click(function(e) {
    $('.active').hide().removeClass('active');
});

$(".search").click(function(e) {
    e.stopPropagation();
});

});

this will allow any link inside a div called activities to toggle a div called search. Works perfect but I wanted to know how to make this universal ie have this script work for any link? Do I have to create a function out of this and assign it to开发者_如何学JAVA the link?


you could bind to the body element

$("#title").click(function(event){
   $("#mailbody").toggle();
     event.stopPropagation();
});

$("body").click(function(){
    $("#mailbody").hide();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消