Differences between jquery objects and DOM objects _ jquery

Source: Internet
Author: User
Jquery objects and DOM objects are frequently used. Because of this, many friends do not know the differences between them. The following describes them in detail, hope to help everyone the first step, http://www.k99k.com/jQuery_getting_started.html
Step 2: The beginner should carefully read the jQuery selector. It is very important !!!
(Http://shawphy.com/jqueryapi/ here is the latest documentation with offline Version Download)
Step 3: understand the differences between jQuery objects and common DOM objects. Mutual conversion: Q1
Q1, js Writing Method: document. getElementById ('save'). disabled = true;
In jquery, I wrote $ ("# save"). disabled = true. Why is it ineffective?

A. This is A typical problem. In fact, $ ("# save") is actually A jQuery object, not A common DOM object.
This is a common problem for beginners.
Solution:
1. Use JQ to write $ ("# save"). attr ("disabled", "true ");
2. convert it to DOM writing $ ("# save") [0]. disabled = true;
Of course, $ ("# save") [0] can also be written as $ ("# save"). get (0 ). It also returns DOM elements.

$ ("# Save"). eq (0) returns the jq object.
$ (Dom object) to get a jq object.

Q2: Obtain the selected checkbox.
A:
Retrieve all selected checkboxes:
$ ("Input: checkbox: checked ")
Check whether a group of checkpoints are selected:
If ($ ("input: checkbox: checked"). length ){}
Checks whether a checkbox is selected.
If ($ ("input: checkbox"). is (": checked ")){}

Q3: My id contains [] or... What should I do? Or the xml tag with a namespace carries: What should I do?
A: escape with \ As shown in


$ ("# Id \ [1 \]")

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.