Jquery encapsulation (learning) 01, jquery encapsulation learning 01
1. during the development process, we often use repeated jquey code. The most common is where we need to copy and paste the code, which greatly increases the redundant code and makes maintenance inconvenient. Why don't we encapsulate the common jquery code and call it wherever necessary?
2. From now on, I have learned how to encapsulate jquery code and started the first jquery encapsulation.
3. you can use jquery to write your own function or library like the original JS, and then reference your js when calling it, and ensure that jquery is also referenced on the page, for example, you write an extension. Then you can reference it on the page in saygoodbye. js.
JQuery. saygoodbye = function () {alert ("good bye"); $ ("body"). hide ();}
4. Page call encapsulated jquery
5. effect:
6. Of course, this is just the simplest jquery encapsulation. In actual project practice, we also need to pay attention to namespaces and other complicated problems.