jquery for Programmer's web interview

Source: Internet
Author: User
Tags jquery cdn

??

Again to the annual graduation season, youth, but waiting for the next opening.

In the job-hunting army, IT industry programmers, code farmers is one of the popular choice of engineering students,

Especially in recent years, the Web is in full swing, attracting thousands of programmers to pursue their dreams,

This article is organized by the experience of the Web interviewer, hoping to help you.

What is jquery?


jquery is JavaScript that writes a reusable JavaScript library.

The JavaScript code that does not use jquery to set UI text is as follows:

document.getElementById ("Txt1"). Value = "Hello";

The JavaScript code behind the jquery class library is as follows:

$ ("#txt1"). Val ("Hello");

As you can see, the JavaScript code behind the jquery class library is significantly simpler and more consistent with IT industry features: short, flat, and fast.

Does jquery replace JavaScript in the relationship between jquery and JavaScript?

JavaScript: Is the most popular scripting language in the Web.

JQuery: is an excellent JavaScript framework. It is a lightweight JS library that is compatible with CSS3 and also compatible with various browsers (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+).

Therefore, jquery is not a substitute for JavaScript; using jquery makes Web development simple.

How do I use the jquery library?

Download the Jquery.js file from jquery.com (the latest jquery version V1.11.1 or V2.1.1). jquery file rules, such as "JQUERY-1.4.1.J S", where 1.4.1 is the version number of the JS file.

Before you develop the Web program, you need to include the JavaScript, the following code:

<script src= "File:///C:/jquery-1.11.1.min.js" type= "Text/javascript" ></script>
What is a CDN (content distribution network)?

One of the most considered issues in developing Web pages is the response of the page on the client computer: the shorter the time, the better the user experience.

One of the key factors restricting the user experience is the browser download Web file size, including *.html, pictures, *.js, *.css and other files.

In order to maximize reuse and save bandwidth, the CDN comes into being: its basic idea is to avoid the bottleneck and link of the Internet which may affect the speed and stability of data transmission, make the content transmission faster and more stable. The goal is to enable users to get the content they need, solve the congestion of Internet networks, and improve the responsiveness of users to websites.

How do I use jquery CDN?

It is recommended to use the official CDN node using the following code:

<script src= "//code.jquery.com/jquery-1.11.0.min.js" ></script><script src= "//code.jquery.com/ Jquery-migrate-1.2.1.min.js "></script>

And the jquery CDN that Google offers:

<script type= "text/javascript"    src= "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/ Jquery.min.js "></script>

Microsoft also provides a node for the jquery CDN:

<script type= "text/javascript"    src= "Http://ajax.microsoft.com/ajax/jquery/jquery-1.9.1.min.js" ></script>

How can I automatically access jquery files for a Web site when the CDN network is inaccessible?

In general, CDN network nodes are reliable.

But occasionally there are failures, so in order to provide double insurance, can judge the Network Load CDN failure, then automatically load jquery on the site

, the sample code is as follows:

<script type= "Text/javascript" src= "Http:/ajax.microsoft.com/ajax/jquery/jquery-1.9.1.min.js" ></script ><script type= "Text/javascript" >if (typeof JQuery = = ' undefined ') {  document.write (unescape ("%3cscript src= ' scripts/jquery.1.9.1.min.js ' type= ' Text/javascript '%3E%3C/script%3E "));} </script>

What is the difference between the same version of Jquery.js file and JQuery.min.js?

Same as :

These two files provide the same functionality of jquery, i.e. there is no difference in function calls.

different :

The Jquery.js file is suitable for programmers to read as shown in:

JQuery.min.js files, by compressing and deleting all the spaces to save bandwidth and space, make the file smaller for network transmission and not suitable for programmers to read.

When to use Jquery.js, when to use Jquery.min.js?

Development Debug Scenario: Use the Jquery.js file because you want to debug and be able to see the JavaScript code.

Production deployment environment: With JQuery.min.js files, you can reduce network width and speed up page loading.

What is a JQuery.vsdoc.js file?

The *.vsdoc.js file is used under Visual Studio in Microsoft's development environment to facilitate the IntelliSense of jquery, and when you enter jquery correspondence, it automatically prompts for the type of function, function usage instructions, function parameters, and so on.

If you develop a Web program with jquery under VS, the Vsdoc.js file will greatly improve your development efficiency.

How does the basic syntax of jquery explain?

The syntactic structure of jquery can be divided into four parts:

    1. By default, all jquery commands start with a "$" symbol.
    2. The second is the selection of HTML elements. For example, let's select an HTML text box by ID "TXT1".
    3. It is then separated by a dot (.). This operator separates the element and the action (function) of the element.
    4. The last kind of function (action).

For example, in the following jquery code, we are setting the text value for "Hello World, JQuery".

What does the "$" symbol mean in jquery?

In jquery, the "$" symbol is an alias for jquery, with the default jquery class library starting with $.

Why use Jquery.noconflict ()

There are many similar libraries like jquery, such as MooTools, Backbone, Sammy, Cappuccino, Knockout. Some of these class libraries also use the $ symbol, which, if used at the same time, causes a naming conflict.

In order to resolve this conflict, jquery.noconflict () needs to be used so that it does not depend on the default symbol.
For example:

$.noconflict (); jquery ("P"). Text ("I am jQuery and I Am working&hellip;");

or use aliases instead:

var jq = $.noconflict (); JQ ("P"). Text ("I am invoked using jquery shortcut&hellip;");
Please illustrate the jquery selector

Select the P element for all HTML and hide

$ ("P"). Hide ();

Select an HTML element with ID TEXT1 and assign a value

$ ("#Text1"). Val ("Hello");

Select Class as the text1dhtml element and assign a value

$(". Text1 "). Val (" Hello ");

In jquery, how do I use Document.ready?

Once the full HTML DOM is loaded, the HTML "Document.ready" event is triggered, and the HTML element is accessed via jquery, and the HTML element of the page needs to be loaded.

For example:

<script>   $ (//  error.) Unable to access </script>

An example of an accessible HTML element in the ready event is as follows:

<script>       $ (document). Ready (function() {           $ ("#text1"). Val ("Sometext"  );       }); </script>
Can I load more than one Document.ready event in the same page?

OK.

How do I attach an HTML element event with jquery?

Here are 2 examples to illustrate

Example 1, select all the button elements, and in their click event, all P elements are toggle.

$ ("button"). Click (function() {$ ("P"). Toggle ();});

Example 2, select an element with ID P1, and in the MouseEnter event, alert.

$ ("#p1"). MouseEnter (function() {  alert ("you entered p1!" );});
How do I use jquery to add styles (style)?

Examples of use are as follows:

$ ("Li"). Filter (". Middle"). AddClass ("selected");

CSS style content is as follows:

<style>       { color:red;} </style>

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.