Tài liệu tham khảo nhanh jQuery
Tài liệu tham khảo jQuery có thể tìm kiếm và in được — selector, thao tác DOM, sự kiện, hiệu ứng, traversing, AJAX và trình hỗ trợ form. Miễn phí.
Selectors
14$('#id')
$('.class')
$('div')
$('*')
$('[name="email"]')
$('a[href^="https"]')
$('ul li:first')
$('ul li:last')
$('tr:eq(2)')
$('li:not(.done)')
$(':checked')
$('div:visible')
$('ul li')
$('ul > li')
Document ready & DOM
10$(function () { /* ... */ });
$(document).ready(fn)
$(window).on('load', fn)
$(this)
$(el)
$('<div class="box"></div>')
$('#box')[0]
$('#box').get(0)
$('.item').length
$('#box').is(':visible')
DOM manipulation
12$('#box').html('<b>Hi</b>')
$('#box').text('Hello')
$('#name').val('Ada')
$('#list').append('<li>x</li>')
$('#list').prepend('<li>x</li>')
$('#box').before('<hr>')
$('#box').after('<hr>')
$('#box').remove()
$('#box').empty()
$('#box').clone()
$('#box').wrap('<div>')
$('#box').replaceWith('<p>')
Attributes & CSS
13$('#img').attr('src')
$('#img').attr('alt', 'Logo')
$('#cb').prop('checked')
$('#cb').prop('checked', true)
$('#img').removeAttr('title')
$('.box').addClass('active')
$('.box').removeClass('active')
$('.box').toggleClass('open')
$('.box').hasClass('active')
$('#box').css('color', 'red')
$('#box').css({top: 0, left: 0})
$('#box').width()
$('#box').height()
Events
12$('#btn').on('click', fn)
$('#btn').off('click')
$('#btn').click(fn)
$('#form').submit(fn)
$('#sel').change(fn)
$('#in').keyup(fn)
$('#list').on('click', '.item', fn)
$('#btn').trigger('click')
$('#btn').one('click', fn)
e.preventDefault()
e.stopPropagation()
e.target
Effects & animation
12$('#box').show()
$('#box').hide()
$('#box').toggle()
$('#box').fadeIn(300)
$('#box').fadeOut(300)
$('#box').fadeTo(300, 0.5)
$('#box').slideUp()
$('#box').slideDown()
$('#box').slideToggle()
$('#box').animate({left: 100})
$('#box').stop()
$('#box').delay(500).fadeIn()
Traversing
12$('#box').find('.item')
$('#box').parent()
$('#box').parents('.row')
$('#box').closest('.row')
$('#box').children()
$('#box').siblings()
$('#box').next()
$('#box').prev()
$('.item').each(fn)
$('.item').filter('.on')
$('.item').first()
$('.item').eq(1)
AJAX
11$.ajax({url: '/api', method: 'GET'})
$.get('/api', fn)
$.post('/api', data, fn)
$.getJSON('/api.json', fn)
$('#box').load('/part.html')
$.ajax({dataType: 'json'})
$.ajax({data: {q: 'x'}})
.done(function (res) {})
.fail(function (err) {})
.always(function () {})
$.ajaxSetup({headers: {}})
Forms
10$('#form').serialize()
$('#form').serializeArray()
$('#name').val()
$('#name').val('Ada')
$(':input')
$('#cb').is(':checked')
$('#sel option:selected')
$('#in').focus()
$('#form').on('submit', fn)
$('#in').prop('disabled', true)
Utilities
11$.each(arr, fn)
$.map(arr, fn)
$.grep(arr, fn)
$.extend({}, a, b)
$.trim(' hi ')
$.inArray(2, arr)
$.isArray(x)
$.isFunction(x)
$.parseJSON(str)
$.now()
$.type(x)
Không có mục nào khớp với “:q”.
Giới thiệu về Tài liệu tham khảo nhanh jQuery
Bảng tra cứu jQuery này là tài liệu tham khảo gọn gàng cho thư viện vẫn đang vận hành một phần lớn các trang web hiện có: selector, document ready và DOM cơ bản, thao tác DOM, thuộc tính và CSS, sự kiện, hiệu ứng và animation, duyệt phần tử, AJAX, biểu mẫu, cùng tiện ích.
Nếu bạn bảo trì các front-end cũ, plugin hoặc theme CMS đời trước, sự thành thạo jQuery vẫn là một kỹ năng thực tế. Mỗi dòng ghép một lời gọi phương thức với mô tả một câu, để bạn có thể nhớ lại chính xác chữ ký hàm cho ủy quyền sự kiện, duyệt phần tử theo chuỗi hoặc một yêu cầu AJAX mà không cần lục lại tài liệu cũ.
Bảng này miễn phí và chạy hoàn toàn phía client. Lọc các phương thức trực tiếp bằng ô tìm kiếm, nhảy giữa các phần từ mục lục cố định, sao chép bất kỳ đoạn mã nào chỉ bằng một cú click và in trang ra khi bạn đang tái cấu trúc sâu một dự án cũ.
Cách sử dụng Tài liệu tham khảo nhanh jQuery
- Lướt qua các phần, từ Selectors và Document ready & DOM qua Traversing đến AJAX và Utilities.
- Tìm một phương thức như on, closest hoặc ajax để lọc bảng trực tiếp.
- Nhảy đến một phần như Effects & animation qua thanh bên cố định.
- Nhấp vào một đoạn mã hoặc biểu tượng sao chép của nó để sao chép lời gọi jQuery vào code của bạn.
- In bảng để tham khảo ngoại tuyến khi làm việc trên các dự án cũ.