[removed] Performance of .className Changes vs. .s

2020-07-23 08:03发布

Back in 2005, Quirksmode.com released this article:

http://www.quirksmode.org/dom/classchange.html

that showed "proof" that changing the style of an element by changing its class (ie. "elem.className = x") was almost twice as fast as changing its style via its style property (ie. "elem.style.someStyle = x"), except in Opera. As a result of that article, we started using a className-based solution to do things like showing/hiding elements on our site.

The problem is, one of our developers would much rather use jQuery's equivalent methods for this kind of thing (ie. "$(something).hide()"), and I'm having a hard time convincing him that our className-based function is worth using, as I can only find a single article written four years ago.

Does anyone know of any more recent or more comprehensive investigations in to this issue?

7条回答
▲ chillily
2楼-- · 2020-07-23 08:58

No, but I can tell you that jQuery.hide() can hide an element with a smooth effect. This cannot be done by changing the className.

查看更多
登录 后发表回答