How jQuery caches variables
This article mainly introduces how jQuery cache variables, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Cache variabl
DOM traversal is expensive, so try to cache the elements that will be reused.
/ / Bad h = $('# element'). Height (); $('# element'). Css ('height',h-20); / / recommended $element = $(' # element'); h = $element.height (); $element.css ('height',h-20) Thank you for reading this article carefully. I hope the article "how to cache variables in jQuery" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!