jQuery
functionjQuery(selector)
or $(selector)
jQuery("div p a")
or $("div p a")
jQuery("div.content td.number")
or $("div.content td.number")
jQuery(function)
or $(function)
jQuery(function() { alert("Hello, World!!!"); })
or $(function() { alert("Hello, World!!!"); })
jQuery(html code)
or $(html code)
jQuery("<strong>Hello!</strong>")
or $("<strong>Hello!</strong>")
jQuery("<div><img src='somewhere' /></div>")
or $("<div><img src='somewhere' /></div>")
jQuery
function: $(...)
ShowHide<script src="http://code.jquery.com/jquery-X.Y.Z.min.js"></script>
size()
get(index)
index(element)
slice(begin, end)
not(expression)
filter(expression)
has(expression)
Selector | Description |
---|---|
* | Matches any element. |
E | Matches all elements with tag name E. |
E | F Matches all elements with tag name F that are descendants of E. |
E>F | Matches all elements with tag name F that are direct children of E. |
E+F | Matches all elements with tag name F that are immediately preceded by sibling E. |
E~F | Matches all elements with tag name F preceded by any sibling E. |
E.C | Matches all elements with tag name E with class name C. Omitting E is the same as *.C. |
E#I | Matches all elements with tag name E with the id of I. Omitting E is the same as *#I. |
E[A] | Matches all elements with tag name E that have attribute A of any value. |
E[A=V] | Matches all elements with tag name E that have attribute A whose value is exactly V. |
E[A^=V] | Matches all elements with tag name E that have attribute A whose value starts with V. |
E[A$=V] | Matches all elements with tag name E that have attribute A whose value ends with V. |
E[A!=V] | Matches all elements with tag name E that have attribute A whose value doesn't match the value V, or that lack attribute A completely. |
E[A*=V] | Matches all elements with tag name E that have attribute A whose value contains V. |
Selector | Description |
---|---|
:first | Matches the first match within the context. li a:first returns the first link that’s a descendant of a list item. |
:last | Matches the last match within the context. li a:last returns the last link that’s a descendant of a list item. |
:first-child | Matches the first child element within the context. li:first-child returns the first list item of each list. |
:last-child | Matches the last child element within the context. li:last-child returns the last list item of each list. |
:only-child | Returns all elements that have no siblings. |
:nth-child(n) | Matches the nth child element within the context. li:nth-child(2) returns the second list item of each list. |
:nth-child(even|odd) | Matches even or odd children within the context. li:nth- child(even) returns the even list items of each list. |
:nth-child(Xn+Y) | Matches the nth child element computed by the supplied formula. If Y is 0, it may be omitted. li:nth-child(3n) returns every third list item, whereas li:nth-child(5n+1) returns the item after every fifth element. |
:even | Matches even elements within the context. li:even returns every even list item. |
:odd | Matches odd elements within the context. li:odd returns every odd list item. |
:eq(n) | Matches the nth matching element. |
:gt(n) | Matches matching elements after and excluding the nth matching element. |
:lt(n) | Matches matching elements before and excluding the nth matching element. |
Selector | Description |
---|---|
:checked | Selects only checkboxes or radio elements in checked state. |
:disabled | Selects only elements in disabled state. |
:enabled | Selects only elements in enabled state. |
:not(selector) | Negates the specified selector. |
Selector | Description |
---|---|
:animated | Selects only elements that are currently under animated control. |
:button | Selects only button elements (input[type=submit], input[type=reset], input[type=button], or button). |
:checkbox | Selects only checkbox elements (input[type=checkbox]). |
:contains(food) | Selects only elements containing the text food. |
:file | Selects only file input elements (input[type=file]). |
:has(selector) | Selects only elements that contain at least one element that matches the specified selector. |
:header | Selects only elements that are headers; for example, <h1> through <h6> elements. |
:hidden | Selects only elements that are hidden. |
:image | Selects only image input elements (input[type=image]). |
:input | Selects only form elements (input, select, textarea, button). |
:parent | Selects only elements that have children (including text), but not empty elements. |
:password | Selects only password elements (input[type=password]). |
:radio | Selects only radio elements (input[type=radio]). |
:reset | Selects only reset buttons (input[type=reset] or button[type=reset]). |
:selected | Selects only |
:submit | Selects only submit buttons (button[type=submit] or input[type=submit]). |
:text | Selects only text elements (input[type=text]). |
:visible | Selects only elements that are visible. |
addClass(names)
removeClass(names)
toggleClass(names)
Adds the 'small' class to all images contained in divs with class 'thumb' (within this block) Execute
Removes the 'small' class to all images contained in divs with class 'thumb' (within this block) Execute
Toggles the 'small' class to all images contained in divs with class 'thumb' (within this block) Execute
Selector | Description |
---|---|
:checked | Selects only checkboxes or radio elements in checked state. |
:disabled | Selects only elements in disabled state. |
:enabled | Selects only elements in enabled state. |
:not(selector) | Negates the specified selector. |
html(content)
text(content)
append(content)
prepend(content)
before(content)
after(content)
appendTo(targets)
prependTo(targets)
insertBefore(targets)
insertAfter(targets)
remove()
detach()
empty()
clone()
val()
val(content)
serialize()
bind(event, handler)
one(event, handler)
unbind(event, handler)
show(speed, callback)
hide(speed, callback)
toggle(speed, callback)
fadeIn(speed, callback)
fadeOut(speed, callback)
slideDown(speed, callback)
slideUp(speed, callback)
slideToggle(speed, callback)
fadeTo(speed, opacity, callback)
Event |
---|
blur |
change |
click |
dblclick |
error |
focus |
focusin |
focusout |
keydown |
keypress |
keyup |
load |
mousedown |
mouseenter |
mouseleave |
mousemove |
mouseout |
mouseover |
mouseup |
ready |
resize |
scroll |
select |
submit |
unload |
XMLHttpRequest
object$.load(url, parameters, callback)
url
: the URL of the server-side resourceparametes
: data to be passed as request parameters (optional)callback
: a function handling retrivied data (optional)$.get(url, parameters, callback, type)
$.post(url, parameters, callback, type)
url
: the URL of the server-side resourceparametes
: data to be passed as request parameters (optional)callback
: a function handling retrivied data (optional)type
: 'html', 'text', 'xml', 'json', 'script', or 'jsonp' (optional)