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 \]")