PHP------The use of jquery

Source: Internet
Author: User

Jquery

jquery is actually equivalent to an upgraded version of the js,jquery inside a lot of things, the function of jquery is more powerful than JS, with more convenient than JS. jquery and JS are all belong to JS, but jquery is encapsulated a JS equivalent, it put JS in some of the things all packaged up, we use more convenient. JS and jquery can be strung, jquery best use jquery,js can not be used, because JS is too troublesome.

If this page is to use jquery, the page needs to refer to a jquery package, jquery packages can be downloaded from the Web.

jquery package, do not need to know how to write, directly to use it.

If this page needs to use jquery, this page must refer to the jquery package, referencing the use of the jquery package, and referencing the external JS is the same.

<script srt= "Jquery-1.11.2.min.js" ></script>

The jquery package is then referenced to the current page.

This page will be able to use jquery syntax.

<title> Untitled Document </title>

<script src= "Jquery-1.11.2.min.js" ></script>

<body><!--do a few div--> in the body

<div id= "One" >one</div>

<div class= "Test" >two</div>

<div class= "Test" >three</div>

<div class= "Test" >four</div>

<input type= "text" name= "UID" id= "UID"/>

</body>

<script type= "Text/javascript" >//write JS code below

Use jquery to add a word

$ is the thing that jquery uses to make a choice, it's like a selector, specifically for the choice.

Brackets () Inside, is based on what things come to choose. Document representative is the current page, to select.

Dian. Can point out the inside of the method.

. Ready (Function (e) method. Ready

The $ symbol inside the parentheses is found by an element of a name, and after an element is found, the point. Ready is the equivalent of adding a ready method, which can be called an event. The ready event means that the page is loaded and the page is loaded to finish one of its events.

We add an event to the document's entire page called page load completion. After the load is complete, the parentheses (function (e) {} is a function, the function is missing a thing, there is no name, so this method is called anonymous function, no Name function. That is, when the page is loaded, it is going to execute this method, which is a no-name, it is bound to the ready event, and when the page is loaded, it comes in and invokes the contents of the method.

Function (e), E is the method in which a parameter is written. The event contains two parameters.

$ (document). Ready (function (e)//write down JS, Jquery code below

{

JS the way

1, through the way JS to find an element, take the element

"1" takes an element by ID

var div = document.getElementById ("one");//This is the way JS based on the ID to take the element, after taking it to a variable var div//So I can according to the ID of one element, the ID is unique is not allowed to repeat. This method only takes a specific element.

alert (div);

The results displayed:

div element. Enough to take this element.

jquery Way

"1" takes an element by ID

Definition: $ ("id");

var div = $ ("#one"); Give a variable var div

() inside according to something to find, the equivalent of a choice, according to what to choose?? Need to give it a parameter, "" to find the element by ID

"#one" is based on the ID of one

alert (div);

is a number group

});//Depending on the document, find the entire page file.

</script>

PHP------The use of jquery

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.