Home > Article > Web Front-end > Introduction to the difference between jquery objects and DOM objects_jquery
The first step, http://www.k99k.com/jQuery_getting_started.html
The second step, novices must read all jQuery selectors carefully, it is very important! ! !
(http://shawphy.com/jqueyapi/ Here is the latest document, there is an offline version for download)
The third step is to deeply understand the difference between jQuery objects and ordinary DOM objects. See Q1 for mutual conversion.
Q1, js writing method: document.getElementById('save').disabled=true;
In jquery, I write it like this $("#save").disabled = true; why It doesn’t work
A, this is a typical problem, in fact, because what comes out of $("#save") is actually a jQuery object, not an ordinary DOM object
This is a common problem for novices.
There are 2 solutions:
1. Use JQ writing method, $("#save").attr("disabled","true");
2. Convert to DOM writing method $("#save ")[0].disabled=true;
Of course, $("#save")[0] can also be written as $("#save").get(0). What it returns is also a DOM element
$("#save"). What eq(0) gets is still a jq object.
$(dom object) can get a jq object.
Q2, get the selected checkbox
A:
Get all the selected checkboxes:
$("input:checkbox:checked")
Judge whether a group of checkboxes are selected :
if($("input:checkbox:checked").length){}
Determine whether a checkbox is checked
if($("input:checkbox").is(":checked ")){}
Q3, there are symbols like [] or . in my ID, what should I do? Or what should I do if the xml tag with namespace has:?
A: Used to escape such as