20 most common jQuery interview questions and answers

There is no doubt that jQuery gives JavaScript urgently rumored boosts, which is useful, but it is always an underestimated language. Before jQuery powder debut, we will write a lengthy JavaScript code, not only For larger applications, sometimes even less applications. That code is often difficult to read and difficult to maintain.

Write the original JavaScript before using this excellent library Just one month after use it, I can realize the true power of jQuery. Given its huge popularity, about jQuery interview questions, and the number of HTML and JavaScript increases in any web developer interview Because jQuery is relatively new, the problems involved in most interviews are around the core jQuery library, including selectors, DOM operations, and jQuery foundations.

In this article, I want to HTML and JavaScript developers share 20 jQuery issues encountered in different interviews. Some of this may also be involved in developing Java web development interviews that require both the server (Spring, Servlet and JSP) and client (HTML, CSS, JavaScript, and jQuery).

If you are going to interview a position, it needs you have multiple skills, such as: Java, jQuery, it doesn’t want you to understand the jQuery every subtle detail, or have a comprehensive understanding, But if you want to interview a real client development position, you need to accumulate more advanced skillful jQuery issues, not limited to these issues listed herein. However, you can quickly tyrann, those who are often mentioned in the jQuery interview, and most of them are also applicable to Web developers with 2 to 5 years of experience, especially Java.

jQuery interview issues and answers
JavaSCRIpt is the standard language of the client-side scripting, JavaScript and jQuery makes writing easier. You can only write a few lines of jQuery code will be able to achieve something more. It is one of the most commonly used JavaScript libraries, and now has very few new projects using native JavaScript is not the jQuery. This means that for as a Java web developer you, you will find many interview questions jQuery in a Java web development interview.

Earlier, mostly HTTP, HTML, CSS and JavaScript, but recently, in addition to the basic JavaScript, and people want to know if you are familiar with jQuery. This issue 16 jQuery is ready for web developers, and you can also be very easy to correct some of the key concepts before attending a round of telephone or video interviews. If you are new to jQuery, it can also help you understand the basics of more good, and inspire you to discover more things.

1. JQuery library $ () What is? (Answer below)

$ () function is a jQuery () function of another name, it is very strange at first glance, but also the jQuery code obscure. Once you get used to, you’ll love its simplicity. $ () Function is used to wrap any object into jQuery object, then you are allowed to a plurality of different methods defined on an object jQuery call. You can even be a selector string passed $ () function, which returns a jQuery object matching all the elements of the array containing DOM. The problem I have seen several times mentioned, although it is very basic, it is often used to distinguish whether a developer to understand jQuery.

2. There are five

elements on the page, how to use jQuery to select them? (Answer)

Another important issue is based on jQuery selector. jQuerY supports different types of selectors, such as ID selectors, Class selectors, tag selectors. In view of this problem, ID and Class are not mentioned, you can use the tag selector to select all DIV elements. jQuery code: $ (“div”), which returns a jQuery object that contains all 5 DIV tags. More detailed answers to the article on the link above.

3. What is the difference between the ID selector and the Class selector in jQuery? (Answer)

If you have used CSS, you may know the difference between the ID selector and the Class selector, JQuery is the same. The ID selector uses the ID to select an element, such as # Element1, and the Class selector uses the CSS Class to select an element. When you only need to select an element, use the ID selector, and if you want to select a set of elements with the same CSS Class, you must use the Class selector. During the interview, you have a big chance that will be required to write code using the ID selector and Class selector. The following jQuery code uses the ID selector and Class selector:

$ (‘# logintextbox’) // Returns Element Wrapped as jQuery Object with id = ‘logintextbox’ $ (‘. Active’) // Returns All Elements with CSS Class Active.
As you can see, from a syntax perspective, ID selector and class selector Another difference is that the former uses characters “#” while the latter uses characters. ” More detailed analysis and discussions see the answer link above.
  4. How to use jQuery hidden when you click on a buttonTibet a picture?  
This is an event handling problem. jQuery provides good support for events such as buttons. You can hide a picture that is positioned by ID or Class by the following code. You need to know how to set an event for the button and execute the hide () method, the code is as follows:

$ (‘# buttonTOCLICK’). Click (function () {$ (‘#Imagetohide’). Hide ();});

I like this problem, because it is close to the actual use, the code is not complicated.

5. $ (Document) .ready () What function? Why use it? (Answer)
 This problem is very important and often asked. The ready () function is used to execute the code when the document enters the READY state. JQuery allows you to perform code when DOM is fully loaded (eg HTML is completely resolved). Using $ (Document) .ready () The biggest advantage is that it applies to all browsers, jQuery helps you solve the problem of cross-out. Users who need further understanding can click on the Answer link to view detailed discussion.   6. What is the JavaScript window.onLoad event and the jQuery ready function? (Answer) 
This question and answer is next to the previous one. The main difference between JavaScript Window.onLoad events and jQuery Ready functions is that in addition to waiting for the DOM to be created, all external resources, including large pictures, audio, and video are fully loaded. If the image and media content take a lot of time, the user will feel that the code defined on the Window.onLoad event is obviously delayed.

On the other hand, jQuery ready () function simply wait for the DOM tree, without having to wait for images to load or external resources to perform them faster. Another advantage of using jQuery $ (document) .ready () is that you can use it many times on the page, the browser will execute them in the order they appear in the HTML page, contrary to onload technology, only single function in use. In view of this benefit, with jQuery ready () function than with JavaScript window.onload event to be better.

7. How can I find selected items all HTML select tags? (Answer below)

This is one interview in the tricky problem of jQuery. This is a basic question, but do not expect every jQuery beginner knows it. You can use the following jQuery selector includes all the selected items on the multiple = true

label:

$ ( ‘[name = NameOfSelectedTag]: selected’)

this code uses a combination of selection and properties: selected selector results returns the selected option. You can modify it as needed, such as using rather than the name attribute id attribute to obtain label.

8. JQuery where each () function is what? How do you use it? (Answer below)

each () function is like inside a Java Iterator, which allows you to traverse a collection of elements. You can pass a function to each () method, jQuery called object performs a function passed on each of its elements. Sometimes the problem will be followed by a question above, for example, how to display all selected items in the alert box. We can spendThe selector code of the face finds all the selected items, and then we print them one by one in the ALERT box, the code is as follows:
   
$ (‘ Name = nameOfselectedTAG]: SELECTED ‘). Each (SELECTED) {Alert ($ (SELECTED) .TEXT ());});

wherein TEXT () Method Returns the text of the option. 9. How did you add an HTML element to the DOM tree? (The answer is as follows)

You can use jQuery method appendto () to add an HTML element to the DOM tree. This is one of the many ways of jQuery. You can add an existing element or a new HTML element at the end of the specified DOM element via the appendto () method.
10. Can you select all the hyperlinks within the paragraph in the jQuery code? (Answer)
   This is another jQuery interview question about the selector. Just like other problems, just one line of jQuery code can get it. You can use the jQuery code snippet to select all the hyperlinks inside the paragraph (
tab) …

11. $ (This) and THIS What is the difference between the keyword in jQuery? (The answer is as follows)

This is a tricky problem for many jQuery beginners, in fact, is a simple problem. $ (this) Returns a jQuery object, you can call multiple jQuery methods, such as getting text with text (), valued values ​​with val (). This generationTable current elements, it is one of the JavaScript keywords, indicating the current DOM element in the context. You cannot call the jQuery method until it is packaged by a $ () function, such as $ (this).

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment