In past episodes, we talked about caching a collection of elements to avoid multiple returns to the DOM to fetch the elements. Let’s talk about it now in the context of the script you are writing. You’ll see an additional “why” of caching.
The variable $ does not have context and does not natively mean jQuery. It can also stand for Mootools and any value. You need to specifically initialize jQuery to the $ variable. Let’s talk about it in relationship to the IIFE. I’ll show you how to pass jQuery into the IIFE (yes, you can pass in objects) and then assign it to the variable for use within the IIFE’s scope.
I bet you’d like to animate an element to increase the front-end interactive. In this episode, you will work with various jQuery effect commands including: hide() show() slideUp() slideDown() You’ll see how to change the duration, which changes the speed of the effect.
Why would you want to use a library like jQuery? Why? It’s all about rapid web development. Libraries and frameworks allow you to write less code, which reduces your development time and costs. Let’s talk about the why of libraries like jQuery.