I get everything but this
// This return statement is used for two reasons
// 1. To make sure we hit every HTML element in the jQuery object
// 2. To make sure that this method doesn't "break the chain"
What does "hit" mean and what is the "chain"? I don't want "everything to
become invisible, just the one container I specify. Wont th is work just
fine?
jQuery.fn.toggleVis = function() {
if(this.style.visibility == 'hidden') {
this.style.visibility = 'visible';
} else {
this.style.visibility = 'hidden';
}
};
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Aaron Heimlich
Sent: Monday, July 23, 2007 6:01 PM
To: [email protected]
Subject: [jQuery] Re: Toggling an objects visiblty without show and hide
jQuery.fn.toggleVis = function() {
// Here, "this" is the jQuery object
// This return statement is used for two reasons
// 1. To make sure we hit every HTML element in the jQuery object
// 2. To make sure that this method doesn't "break the chain"
return this.each(function() {
// Iterate over all selected HTML elements and toggle their
"visibility" CSS property
// Here, "this" a HTML element
if(this.style.visibility == 'hidden') {
this.style.visibility = 'visible';
} else {
this.style.visibility = 'hidden';
}
});
};
Usage: $('mySelector').toggleVis();
On 7/23/07, Mitchell Waite < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:
I like jQuery effects show and hide but they actually remove the object from
the screen. So an <H1> under an image will move up.
Can someone show me the best way to change (toggle) an objects "visibility"
property between "hidden" and "visible" so any HTML under it will not move.
Mitch
--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com