Get the App
SLTechnology News&Howtos  ›  Development  › 

How jQuery caches variables

Shulou Source: shulou.com Published: 2022-06-01 04:19:27 09月22日 Update

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!

Tags: Caching articles variables bad expensive value elements interests at the same time suggestions more friends knowledge editing industry information information channels channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei Apple NVidia macOS