JavaScript style.display=none or jQuery .hide() is more efficient?

JavaScript style.display=none or jQuery .hide() is more efficient?

Talking about efficiency:

document.getElementById( elemtId ).style.display = none;

What jQuery does with its .show() and .hide() methods is, that it remembers the last state of an element. That can come in handy sometimes, but since you asked about efficiency that doesnt matter here.

a = 2;

vs

a(2);
function a(nb) {
    lot;
    of = cross;
    browser();
    return handling(nb);
}

In your opinion, what do you think is going to be the fastest?

JavaScript style.display=none or jQuery .hide() is more efficient?

Efficiency isnt going to matter for something like this in 99.999999% of situations. Do whatever is easier to read and or maintain.

In my apps I usually rely on classes to provide hiding and showing, for example .addClass(isHidden)/.removeClass(isHidden) which would allow me to animate things with CSS3 if I wanted to. It provides more flexibility.

Leave a Reply

Your email address will not be published.