Questions on jquery related surfaces

Source: Internet
Author: User
Tags getscript

1 How do you use jquery in the company?

A: What is used in the project is to see if you have project experience (according to your actual situation to answer) you used the selector Ah, check box ah, form AH, Ajax Ah, events, etc.

Configuring the jquery Environment Download the jquery class library on the JSP page referencing the jquery class library

<script type= "Text/javascript" src= "Jquery/jquery-1.7.2.min.js"/>

Next pass in <script> $ (function () {}); </script>

2. Why do you want to use jquery?

A: Because jquery is a lightweight framework, less than 30kb in size, it has a powerful selector, an excellent DOM manipulation package, a reliable event handling mechanism (jquery is fairly reliable when handling event bindings), Perfect Ajax (its Ajax package is very good, There is no need to consider the compatibility of complex browsers and problems with the creation and use of XMLHttpRequest objects. ) Excellent browser compatibility. It also supports chained operations, implicit iterations. The separation of the behavioral and structural layers, as well as the rich plug-ins, also enrich the documentation for jquery.

3. What do you think are the benefits of jquery? Answer Ibid. 4 What problems have you encountered with jquery and how did you solve them?

A: This answer is developed to see if you have relevant project experience.

Example the foreground does not get the value, JSON but the error (more a space, etc.) this compilation is not error the jquery library conflicts with other libraries:

1> If other libraries were imported before the jquery library

1. We can over-control the variable by jquery.noconflict () to other libraries

2. Custom shortcut keys, catch jquery.noconflict with a variable ()

3. Pass the function parameter

2> If the jquery library was imported before another library, use jquery directly

Today, when dealing with a data problem, it is found that the value returned by the Jquery.ajax () method is always problematic, the data is cleared after the cache has been erased, the value returned after multiple tests has been found to be the previous value, and the URL has not been executed (background Java, set breakpoint has not been entered). On the web, find out why the type is not set. If the Jquery.ajax type= "Post" is not set, then Ajax defaults to Type= "Get", which results in the previous data being cached. Plus type= "Post", problem solved!

5 Do you know the selectors in jquery, please tell me what selectors are available?

A: The selectors in jquery are broadly divided into: basic selector, hierarchy selector, filter selector, form selector

6 Is there a difference between a selector in jquery and a selector in CSS?

A: The jquery selector supports the selectors in CSS, the jquery selector can be used to add styles and add the corresponding behavior in the CSS selector is only to add the appropriate style

7 What do you think is the advantage of the selectors in jquery?

A: Simply writing $ (' ID ') to replace the document.getElementById () function

Support CSS1 to CSS3 selector perfect processing mechanism (even if you write the wrong ID will not error)

8 Do you have anything to pay attention to when using selectors?

A: The 1 selector contains ".", "#", "[" and other special characters that need to be translated

2 quotation mark problems with the property selector

3 Considerations for inclusion of spaces in selectors

9 How are jquery objects and Dom objects converted?

A: jquery-to-dom object: The jquery object is an array object that can be obtained by [index] richness and the corresponding DOM object can be obtained through get[index]. Dom object to jquery object: $ (DOM object)

10 How do you use Ajax in jquery?

A: If it is a regular AJAX program, use Load (), $.get (), $.post (), it can be done, generally I will use the $.post () method. If you need to set Beforesend (pre-commit callback function), error (post-failure processing), success (post-processing) and complete (post-request processing) callback function, etc., this time I will use the $.ajax ()

11 Do you find Ajax in jquery useful?

A: useful. Because jquery provides some quick and easy operations for everyday development, such as Load,ajax,get,post, and so on, so using jquery to develop Ajax will be extremely simple and we can focus on the business and user experience, There is no need to bother with the tedious XMLHttpRequest objects.

Is there a difference between $.get () submission and $.post () submission in jquery?

A: the 1 $.get () method uses the Get method to make an asynchronous request. The $.post () method uses the Post method to make an asynchronous request.

A 2 GET request passes parameters after the URL, and the POST request is sent to the Web server as the entity content of the HTTP message, which is not visible to the user.

3 Get mode transfer data size cannot exceed 2KB and post is much larger

4 The data requested by the Get method is cached by the browser, so there is a security issue.

How does the Load method in jquery work in general?

A: The Load method is typically used when loading remote HTML code into the DOM and is usually used to obtain a static data file from a Web server. If you want to pass parameters, you can use $.get () or $.post ().

14 How do you manipulate styles in jquery?

Answer: AddClass () to append style, Removeclass () to delete style, toggle () to toggle style

15 Simple Apple told how does jquery handle events, and what events have you used?

A: First to load the document, after the page home is finished, the browser will use JavaScript to add events to the DOM element.

16 Have you used the animation in jquery, and how is it used?

A: Used.

Hide () and show () modify multiple style properties at the same time. Like height, width, opacity. FadeIn () and fadeout () FadeTo () only change the opacity

Slideup () and Slidedown () Slidetoggle () only change height

Animate () is a method of custom animation.

17 Have you ever used a plugin in jquery? A: Look at the personal strength and experience to answer. 18 What do you usually use to submit data, and why?

A: Generally I will use the $.post () method.

If you need to set Beforesend (pre-commit callback function), error (post-failure processing), success (post-processing and complete (post-request processing) callback function, etc., this time I will use the $.ajax ()

19 There are several ways to introduce CSS in jquery?

Answer: Four kinds of inline, in-line, import-type, link-type

20 What are the differences between the methods you used to insert nodes in jquery?

A: Append (), AppendTo (), prepend (), Prependto (), after (), InsertAfter (), before (), insertbefore () can be broadly divided into internal append and externally appended append () Table appends content to each element. AppendTo () indicates that all elements are appended to the specified element. Example $ (a) AppendTo (b) is analogous to the following method of appending a to B.

21 Have you used the method of wrapping nodes, what are the advantages of wrapping nodes?

A: Wrapall (), wrap (), Wrapinner () should use these packages when inserting additional structured tags into the document should not silk painting the semantics of the original document

How do I get or set properties in jquery?

jquery can use the attr () method to get and set the Element property Removeattr () method to delete element properties

23 How do I set and get the values of HTML and text?

A: The HTML () method is similar to the innerHTML property that can be used to read or set HTML content in an element

Note: HTML () can be used for XHTML documents that cannot be used in an XML document text () similar to the InnerText property that can be used to read or set an element in the Chinese content. Val () can be used to set and get the value of an element

24 What methods do you have in jquery to traverse nodes?

A: Children () gets a collection of child elements of the matching element, considering only that the child element does not consider the descendant element next () gets the sibling element immediately behind the matching element

Prev () Gets the sibling element immediately preceding the match element

Siblings () gets all the sibling elements before and after the matching element

Closest () Gets the closest match element

Find () Gets a collection of elements in the matching element including descendants and descendants

25 What is the difference between a child element selector and a descendant selector element?

A: The descendant element is to find all the elements under the child node, the descendant element is to find the child node or child node in the child node of element 26 in jquery can replace the node?

A: There are two ways to replace nodes in jquery replacewith () and ReplaceAll () For example, <p title= "Hao is You" >hao is you</p> replaced with <strong& Gt;i am fine<strong>$ (' P '). ReplaceWith (' <strong>i am fine</strong> '); ReplaceAll and ReplaceWith use before and after a change can be.

27 What do you think is the use of the Beforesend method?

A: You can modify the function of the XMLHttpRequest object before sending the request, and in Beforesend, you can cancel the AJAX request if you return FALSE. The XMLHttpRequest object is the only parameter so it can be verified in this method.

The siblings () method and the $ (' prev~div ') selector are the same?

A: $ (' prev~div ') can only select the peers <div> elements behind the ' #prev ' element and the siblings () method is independent of the front and back of the civilian, as long as the sibling nodes are matched.

29 Have you used JSON in Ajax, and how do you use it?

A: Used, when the $.getjson () method is.

Because $.getjson () is used to load the JSON file

30 what are the selectors for the query nodes?

A: I used in the company: First query, the last query,: Odd query odd but index starting from 0: Even query even,: the EQ (index) query is equal,: GT (Index) query is greater than index,: LT query is less than index: Header Select all headings, etc.

Can Nextall () replace the $ (' Prev~siblindgs ') selector?

Answer: Yes. Use Nextall () and use $ (' Prev~siblindgs ') is the same

There are several ways to set and get styles in jquery

Answer: AddClass () method, attr () method

$ $ (document). What is the difference between the ready () method and the window.onload?

A: Two methods have similar functions, but there are differences in the timing of implementation. The 1window.onload method is executed when all the elements in the Web page, including all associated files of the element, are fully loaded into the browser.

2 $ (document) the Ready () method manipulates the DOM as it is loaded and invokes the function that performs the binding.

How does jquery handle caching?

A: To handle caching is to disable caching.

1 by using the $.post () method to obtain data, the default is to disable caching.

2 by using the $.get () method to obtain data, you can avoid caching by setting a timestamp. You can add a + (+new Date) Example $.get (' Ajax.xml? ') after the URL. + (+new Date), function () {//content}); 3 Use the $.ajax method to obtain the data, as long as the cache:false can be set.

What is the difference between the $.getscript () method and the $.getjson () method?

A: the 1 $.getscript () method can load the. js file directly, and the JavaScript file is automatically executed without the need to process the JavaScript file.

2 $.getjson () is used to load JSON files, usage and $.getscript ()

36 Have you read the book on jquery?

jquery Basics Tutorial, jquery combat, Sharp jquery, jquery, jquery user Interface Library Learning guide, etc.

PNS $ ("#msg"). Text (); and $ ("#msg"). Text ("<b>new content</b>"); What's the difference?

A: 1 $ ("#msg"). Text () is the textual content of the element node that returns the ID MSG

2 $ ("#msg"). Text ("<b>new content</b>"); is to write "<b>new content</b>" as a plain text string in the element node content with ID msg, and the page displays a bold <b>new content</b>

The second element of the radio Radio Group is the currently selected value, how do I fetch it?

Answer: $ (' input[name=items] '). Get (1). checked = true;

What is the difference between id,class in the 39 selector?

A: Each ID name can be used only once in a webpage, and class can allow reuse

40 What data formats have you used, and what are their characteristics?

Answer: HTML format, JSON format, javascript format, XML format

1 HTML fragments providing external data is generally the simplest.

2 JSON, which has an advantage in performance and file size, is often a good choice if the data needs to be reused and other applications may be affected at one time.

3 and when the remote application is unknown, XML can provide the most reliable guarantee for good interoperability.

What can jQuery do?

A: 1 Gets the elements of the page

2 Modifying the appearance of a page

3 Changing the size of the page

4 Responding to User's page actions

5 Adding a dynamic effect to a page

6 No need to refresh the page, that is, you can get information from the server

7 Simplifying common JavaScript tasks

42 There are several main ways to data in Ajax?

A: Three kinds, HTML stitching, JSON array, form form is serialized by Serialize ().

What is the difference between hover () and toggle () in 43:jquery?

Answer hover () and toggle () are two synthetic events in jquery.

The hover () method simulates a cursor hover event. The toggle () method is a continuous click event.

44 Do you know the events in jquery bubble, how it executes, how to stop the bubbling event?

A: You know, event bubbling is triggered from the inside out. The Stoppropagation () method is available in jquery to stop bubbling.

45 For example, click the hyperlink will automatically jump, click the "Submit" button after the form will be submitted, etc., and sometimes I want to block these default behavior, what should I do?

Answer: You can use Event.preventdefault () or return False in the event handler, that is, return false;

How many verification methods are there before 46.jquery form submission? What is the difference??

A) FormData: Returns an array that can be checked by a loop call to verify

b) Jaform: Returns a JQuery object, all of which need to be converted to a DOM object first

c) Fieldvalue: Returns an array of Beforesend ()

47. Have you ever written a plugin in jquery, and what are the benefits of plugins? Have you written those plugins? Should it pay attention to those?

A) A: the benefits of plug-ins: Encapsulation of existing series of methods or functions for reuse in other places for later maintenance and improvement of development efficiency plug-in classification: Encapsulating object Method Plug-in, encapsulating global function plug-in, selector plug-in

b) Place of attention:

I. 1. The file name of the plugin is named jquery. [plugin name].js to avoid confusion with other JavaScript library plugins

Ii. 2. All object methods should be attached to the Jquery.fn object, and all global functions should be attached to the jquery object itself

Iii. 3. Plug-ins should return a jquery object to ensure the plug-in's chained operation

Iv. 4. Avoid using $ as an alias for jquery objects inside a plug-in, instead use full jquery to avoid conflicts or use closures to avoid

V. 5. All methods or function plug-ins, should be a good end, or compression may occur when the problem. Add a semicolon to the plugin's head, which will prevent other people's irregular code from affecting the plugin.

Vi. 6. Encapsulating the global function through $.extent ({}) in the plug-in, the selector plug-in, extending the existing Object object through $.fn.extend ({}) Encapsulating the object method plug-in

Questions on jquery related surfaces

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.