jQuery 笔记

API 文档

http://api.jquery.com

API 中文文档 https://github.com/shawphy/jquery-api http://jquery-api-zh-cn.googlecode.com/svn/trunk/xml/jqueryapi.xml

jQuery 选择器 Lab:http://codylindley.com/jqueryselectors/

速查表

包裹

.unwrap()

Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.

.wrap()

Wrap an HTML structure around each element in the set of matched elements.

.wrapAll()

Wrap an HTML structure around all elements in the set of matched elements.

.wrapInner()

Wrap an HTML structure around the content of each element in the set of matched elements.

内部插入

.append()

Insert content, specified by the parameter, to the end of each element in the set of matched elements.

.appendTo()

Insert every element in the set of matched elements to the end of the target. Also in: Attributes

.html()

Get the HTML contents of the first element in the set of matched elements or set the HTML contents of every matched element.

.prepend()

Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.

.prependTo()

Insert every element in the set of matched elements to the beginning of the target.

.text()

Get the combined text contents of each element in the set of matched elements, including their descendants, or set the text contents of the matched elements.

应用

监视<a>链接的点击行为并追加参数

$(document).ready(function() {
	$('a').click(function(event) {
		event.preventDefault();	
		var href=$(this).attr('href');
		href += "?id=123";
		windows.location.href = href;
	}); 
});