jQuery documentation commonly used

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

 

 

2. Operation

//property operation

 

 

// advanced filter

 

find

 

// 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');
        });

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325169864&siteId=291194637