Chinese document address: http://jquery.cuishifeng.cn/
jQuery object and DOM object conversion
$('#i1')[0] ==> document.getElementById('i1')
$(document.getElementById('i1')) ==> $('#i1')
1. Find
$('#i1')
$('.i1')
$('div')
//combination
$('div,.i1')
//level
$('i1 div') all divs under i1
$('i1>div') //div in i1 child
$('i1~div') //All sibling div tags after i1
//basic filter
:first
:last
:not(:checked) // In jQuery 1.3, complex selectors are already supported (eg :not(div a) and :not(div,a))
:even
:odd
:eq(0) //first index
:gt(2) //after the third index
:lt(2) //before the third index
// attribute selection
$('[Eric]')
$('div[Eric="Funky"]')
//form
-
form
-
form object properties
2. Operation
//property operation
-
Attributes
-
CSS class
-
HTML code/text/value
// advanced filter
find
- children([expr])
- find (e | o | e)
- next([expr])
- nextAll([expr])
- nextUntil([e|e][,f])
- parent([expr])
- parents([expr])
- parentsUntil([e|e][,f])
- prev ([expr])
- prevAll([expr])
- siblings([expr])
// example
$('.menu-item').click(function(){ $(this).addClass('active').siblings().removeClass('active'); var target = $(this).attr('a'); $('.content').children("[b='"+ target+"']").removeClass('hide').siblings().addClass('hide'); });