In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the front-end jQuery interview questions, which have 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.
1. Advantages of jquery
JQuery is a lightweight framework, less than the size of 30kb
It has powerful selector, excellent encapsulation of DOM operation, and reliable event handling mechanism.
Perfect ajax, excellent browser compatibility
And support chain operation, implicit iteration.
The separation of behavior layer and structure layer also supports rich plug-ins, and the documentation of jquery is also very rich.
2. What types of selectors are there in jQuery?
Hierarchical selector: also known as a path selector, you can select the corresponding DOM elements according to the path hierarchy. Parent > child,prev + next, prev ~ siblings
Form selector:: input,: text,: password,: radio,: checkbox,: submit, etc.
Basic filter selector:: first,:last,: not,: even,: odd,: eq,: gt,: lt content filter selector:: contains,: empty,: has,: parent visibility filter selector:: hidden,: visible attribute filter selector: [attribute], [attribute=value], [attributive attribute value], [attribute^ = value], [attribute$=value], [attribute*=value] child element filter selector: nth-child, first-child: : last-child,: only-child form filter selector:: enabled,: disabled,: checked,: selected
3. What's the difference between $(this) and this keywords in jQuery?
$(this) returns a jQuery object on which you can call multiple jQuery methods, such as getting the text with text (), getting the value with val (), and so on.
This represents the current element, which is one of the JavaScript keywords that represents the current DOM element in the context. You cannot call the jQuery method on it until it is wrapped in a $() function, such as $(this).
4. What's the difference between the $(document) .ready () method and _ window.onload?
The _ window.onload method loads all the elements of the page, including all elements such as images. It can only be executed once.
The $(document) .ready () method is executed after the DOM structure is drawn, without having to wait until it is loaded. It means that when the DOM tree is loaded, it is executed, without having to wait until the images or other external files on the page are loaded. And you can write multiple .ready.
So the execution time of $(document) .ready is earlier than _ window.onload
6. Is there any difference between selector in jquery and selector in css?
JQuery selectors support selectors in CSS
The jQuery selector can be used to add styles and behaviors
The selector in CSS can only add the corresponding style
7. Common methods of operating styles
AddClass () add style
RemoveClass () delete style
Toggle () toggles styles
8. How to get or set properties in jquery?
In jQuery, you can use the attr () method to get and set element attributes.
Delete element attributes with the removeAttr () method
9. Common methods of traversing nodes in jquery
Children () gets the child elements, considering only the child elements and not the descendant elements
Next () gets the next neighboring sibling element
Prev () gets the last neighboring sibling element
Siblings () gets all the siblings of the current element (except itself)
Parents () gets all the ancestor elements of the current element.
Find () gets the set of elements in the matching elements, including offspring and descendants
10. What's the difference between hover () and toggle () in jQuery?
Hover (fn1,fn2): a method that mimics hovering events (moving the mouse over and out of an object). When the mouse moves over a matching element, the first function specified is triggered. When the mouse moves out of this element, the second function specified is triggered.
/ / set class to over when the mouse is over a row of the table, and out when leaving. $("tr") .hover (function () {$(this) .addClass ("over");}, function () {$(this) .addClass ("out");})
Toggle (evenFn,oddFn): toggles the function to be called each time you click. If a matching element is clicked, the first function specified is triggered, and when the same element is clicked again, the second function specified is triggered. Each subsequent click repeats the call to these two functions.
/ / rotate to add and delete a class named selected with each click. $("p") .toggle (function () {$(this) .addClass ("selected");}, function () {$(this) .removeClass ("selected");}) Thank you for reading this article carefully. I hope the article "what are the front-end jQuery interview questions" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.