On May 28 Thursday Five o'clock in the afternoon, the time, received XXX sister's phone, are you xxx? Prepare, Friday 8:30 A.M. to go to the ocean interview, all the way to travel, bumpy winnow, due to the small series of Carsick, with dizzy of brain, small series on the silly to interview, warm reminder, motion sickness of small partner home standing motion sickness medicine, about the ocean interview some summary, small series will follow up in blog post, Want to have some help in the need of small partners, through the interview to find the interviewer a lot of questions about jquery knowledge, when young, learning jquery, think of is a bitter tears, so, small series of inspirational and then the relevant knowledge of jquery to review, the relevant knowledge points summarized into the blog, Small partners with different opinions are welcome to discuss the exchange. Today, I would like to share with you some overview of jquery, the environment and a simple example of getting started.
Some small partners may ask, am I fit to study the jquery course? Small to tell you, it is certainly suitable, like falling in love, the beginning, you can not be very good judge the other side is not the person you spend your life, from the acquaintance of the friend, need a process, for the preparation of Ajax foreground development, familiar with JS, understand Ajax, want to improve their technology, small partners, Want to master the use of jquery small partners are suitable to learn this course, through the study of jquery, we will learn the use of jquery API, some small instances of the implementation method, some HTML, CSS, JS little knowledge. Well, the next small part of the simple introduction of the first example of jquery, the user elite, we come to a simple analysis of this small example, first of all, we look at the server-side thinking analysis, for the specified user name such as Dingguohua return user name already exists, to other user names, return user name can be used, First of all we may have the path structure of the entire example as follows:
First, we need an HTML file, a small part of her name as userverify, in addition we need to write CSS and JS files, from the way we follow the web standards, we have to put CSS and JS files separately, in order to facilitate the management, we set up CSS and JS file directory, Put these two types of files, in addition, we may use the picture, we need to create a separate images file directory, put some picture information, the first step to complete this small example is to write our HTML file, To make sure that some of the content information needed in the page is represented by some HTML tags, let's look at how to write the code for our HTML file:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
We analyze the above code, DOCTYPE information, can tell the browser how to render our page, how to identify the display page information, first we add the page title, and then, in order to avoid the Chinese garbled problem, we took the form of UTF-8, in the above code, We have specified the page to use the CSS file, the CSS file placed under the CSS file, corresponding to the file directory under the establishment, in addition, need to introduce this page to use the JS file, here need two JS file one is jquery, the other is our own compiled JS file, Also add these two files to the JS directory. Then we look at the content in Body,body that is really presented to the user. When the HTML code finished, we found that the final page compared to the page, but the style is not the same, this time need to solve the problem through CSS, HTML is responsible for the content of the page, style through the CSS to solve, and then we write the CSS code, as follows:
the border of the. usertext{/* Control text box is a solid red line */ border:1px solid red; Background-image:url (.. /images/userverify.gif); Background-repeat:repeat-x; Background-position:bottom; }
Accordingly, in JS we also want to build two files, a jquery a userverify, in view of the jquery code more, so the small series has uploaded related resources, the need for small partners to the link to download, and then we write userverify code, To add capacity to the grooming page, the code looks like this:
/** need to do two things through JavaScript code *1.button the myth of being pressed, need to get the data of the text box, and then send to the server side, finally accept the server side of the data returned, fill in the div we reserved, so that we can see the results. Text box, After the user keys, you need to determine whether the contents of the text box is empty, if not empty, the red border and the background map should be canceled, otherwise reserved * *//** need to be registered on the page load completion of these work **/$ (document). Ready (function () {// This is the content of the page loaded after the execution of the code var usernamenode=$ ("#userName");//need to find the button, register the event $ ("#verifyButton"). Click (function () {//1. Get the contents of the text box var username=usernamenode.val ();//2. Send this content to the server-side if (username== "") {alert ("User name cannot be empty");} Else{$.get ("Http://127.0.0.1:8080/JQuery/UserVerify?userName=" +encodeurl (Encodeurl) (UserName)), Null,function ( Response) {//3. Accept server-side returned data, populate the DIV with $ ("#result"). HTML (response);});} ); /need to find a text box, register event Usernamenode.keyup (function () {//Get the contents of the current text box var value=usernamenode.val (), if (value== "") {//Let the border turn red, and also with background figure usernamenode.addclass ("Usertext");} else{//remove border and background image Usernamenode.removeclass ("Usertext");})})
let's look at the running effect as shown in:
Small example, small part of the demonstration here, through this small example, we know that HTML is responsible for page content, CSS is responsible for page style, JS responsible for page behavior, HTML should have DOCTYPE to tell the browser rendering display, border Zodiac can control the page element of the border, background-*** can control the background map, as well as the position of the background map, repeated display of the way and so on, these small knowledge points, we can get a full understanding in this small example, to supplement a small knowledge point, sent to the server side of the data in JS to do conjunctions Encodeurl, Then the server side of the code in accordance with UTF-8 to do a urldecode, can solve the problem of garbled in Chinese.
Small Editor's note: this blog, the small part of the main simple introduction of the basic knowledge of JQuery, and then give a simple user of the famous school example, the end of the article, a simple summary of some features of jquery, Write Less,do more;jquery is designed head change the the-the-right-of-the-go, support for a variety of mainstream browsers, including IE6 and above, based on a powerful CSS selector, almost all operations first use the selector to find DOM objects, and then perform various operations on them; Mask browser differences , the DOM operation provides a convenient extension, with a powerful plug-in mechanism. jquery study, not to be continued ~~~~~~
A summary of the first---of jquery and its introductory examples