For information, the reason that works is that setting {visibility:hidden} hides the element but the element's box still affects layout. Setting {display:none} suppresses box generation altogether. (From http://www.w3.org/TR/REC-CSS2/visufx.html#visibility)
--rob On 7/24/07, Aaron Heimlich <[EMAIL PROTECTED]> wrote:
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]> 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
-- Rob Desbois Eml: [EMAIL PROTECTED] Tel: 01452 760631 Mob: 07946 705987 "There's a whale there's a whale there's a whale fish" he cried, and the whale was in full view. ...Then ooh welcome. Ahhh. Ooh mug welcome.