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();
});
精彩评论