Last Updated: February 25, 2016
·
244
· florenceokosun

JQuery Tips

// Instantaneously hide all divs
$( "div" ).hide();

// Instantaneously show all divs that have the hidden style class
$( "div.hidden" ).show();

Whats going on here: CSS display property is set to none when jQuery hides an element. Implies that the content will have zero width and height; it does not mean that the content will simply become transparent and leave an empty area on the page.

see more on JQuery Website http://api.jquery.com/category/effects/

2 Responses
Add your response

This looks like a quite expensive operation, especially when you have a lot of <div>'s: https://github.com/jquery/jquery.com/issues/88

over 1 year ago ·

state your reason please!
Also from that link you posted, you might want to take a took again, let me quote scottgonzalez:

Let's assume .show() and .hide() are bad and therefore should not be used. How can a plugin developer show and hide elements if they can only do so through classes and every other plugin developer and page author must do the same, with no standard classes to be used?

I'd say @paulirish summed it up well with the question:

Is baking in support for these two edge cases into one of jQuery's most simple looking APIs worth being the largest bottleneck in this editor?

It's not even just the bottleneck, I don't think we can reasonably expect any solution other than .show() and .hide() to work for many developers.

over 1 year ago ·