Learn about the jquery journey

Source: Internet
Author: User

Long heard of the name of jquery, has not studied carefully, through the reading of some of the data collected, feel jquery is really powerful. decided to start their own learning jquery trip. Here is not for you to explain jquery (know the level is limited), but to share their own learning results to everyone, learn and communicate together.

Introduction to jquery

The jquery I understand is a powerful JavaScript class library that encapsulates many of the existing methods and properties. Enables developers to develop the effects they want to achieve faster and with little code. Too much jquery here is not much to introduce, presumably a lot of people have read more detailed documents, I will not wordy.

Selectors (selector)

Using $ in jquery, you can easily get the element by the ID of the element, CSS class, or tag name.

(1) Easy to get elements

Example:

$("p") //获取所有的P元素
$("#pid") //通过 ID
$(".p") //通过css class name

(2) Of course, his function is not limited to this, but also can drill the hierarchy

Example:

$("table > tbody > tr") //获取Table的所有行

$("#t1 > tbody > tr") //获取t1 中所有行

$(".table > tbody > tr") // 获取css类名为.table的所有 行

(3) jquery provides a powerful filter to enable developers to select the appropriate elements more accurately and conveniently:

Example:

$(“p:first”)  //first
$(“p:last”)  //last
$(“table > tbody > tr:even”)  //even rows
$(“table > tbody > tr:odd”) //odd rows
$(“p:eq(1)”) //索引为1
$(“p:gt(2)”) //2以上的元素
$("p:lt(10)”) // 0-9
$(“p:empty”) //没有子孩子的p
$(“p:parent”) //为父的p

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.