The snippet library.
Small, practical examples. Search by task or narrow things down below.
Add a CSS class
jQuery: Learn how to add a CSS class in a complete browser example.
jQuery✓ Tested
Animate a numeric CSS property
jQuery: animate interpolates supported numeric properties to their final values.
jQuery✓ Tested
Animate relative to the current value
jQuery: A plus-equals value adds to the current numeric CSS value.
jQuery✓ Tested
Append a list item
Build a jQuery element with text and append it safely.
jQuery✓ Tested
Append a safely constructed list item
jQuery: Learn how to append a safely constructed list item in a complete browser example.
jQuery✓ Tested
Apply classes from explicit Boolean state
jQuery: The second toggleClass argument applies a known state consistently.
jQuery✓ Tested
Attach an application-specific request header
jQuery: The headers option adds a header to this request only.
jQuery✓ Tested
Attach configuration when registering a handler
jQuery: event.data carries the registration-time data object.
jQuery✓ Tested
Cancel a pending request
jQuery: abort rejects the jqXHR with the abort status.
jQuery✓ Tested
Check native form validity before proceeding
jQuery: Use the native checkValidity API from the selected form.
jQuery✓ Tested
Check whether any selected element matches
jQuery: is returns a Boolean without changing the selection.
jQuery✓ Tested
Clear a container’s contents
jQuery: Learn how to clear a container’s contents in a complete browser example.
jQuery✓ Tested