jQuery 笔记
API 文档
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/
速查表
包裹
Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
Wrap an HTML structure around each element in the set of matched elements.
Wrap an HTML structure around all elements in the set of matched elements.
Wrap an HTML structure around the content of each element in the set of matched elements.
内部插入
Insert content, specified by the parameter, to the end of each element in the set of matched elements.
Insert every element in the set of matched elements to the end of the target. Also in: Attributes
Get the HTML contents of the first element in the set of matched elements or set the HTML contents of every matched element.
Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
Insert every element in the set of matched elements to the beginning of the target.
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; }); });
- Line 3:阻止浏览器的默认行为,例如是click事件就阻止浏览器跳转到指定URL。
- If this method is called, the default action of the event will not be triggered(触发).For example, clicked anchors(锚) will not take the browser to a new URL. We can use event.isDefaultPrevented() to determine(确定) if this method has been called by an event handler that was triggered by this event.
- Details: jQuery API