Let’s put it this way, only with a solid foundation in JavaScript can you use various JS libraries with ease, and then let’s get to the point!
1. Let’s talk about the efficiency of JQuery first
He The speed of the selector is about 4 times slower than the standard JS Dom (officially said, I am not making it up...), so why do we still use it? The reason is very simple, the first JS is For client-side applications, the speed impact is not so obvious, but you must pay attention to when to use JQuery selectors and when to use JavaScript selectors!
This is my personal understanding, if the logic is easier when selecting objects Then don't use JQuery's selector, such as
Then just do simple verification, no complicated operations, just use document.getElementById("name" );
Don’t use JQuery’s $("#ID") just because it looks convenient, but if you want to do more complex and logical operations, use JQuery. For example, there are 10
When we want to delete the rows they are in after checking
$("input[checked]").parent().parent().remove(); This way of writing is in It is better in terms of logic and maintainability!
2. Let’s talk about cross-browser aspects
Generally, when writing JavaScript, there is code. If you want to run on different browsers, some methods The problem is that it is not supported by the browser and must be modified. JQuery has done a better job in this regard and supports mainstream browsers, so that one code can be used on multiple browsers
3. Next, let’s talk about "Zonghai Development"
Nowadays development emphasizes high speed, high quality and easy maintenance. It can be written from scratch using traditional JavaScript, but it will cause problems in the development progress. It has a great impact, and JQuery has a rich plug-in library, which greatly improves development efficiency. You may say that with so many plug-in libraries, just looking at the API is exhausting, but JQuery has done a good job in this regard. Each plug-in has Detailed comments and Domo make it easy to put it into practical applications.
This is my first time writing something. Don’t be angry if I don’t write well. The next article will introduce some techniques for applying JavaScript and JQuery in actual development. ,Thank you