Skip to content

Instantly share code, notes, and snippets.

@steveclarke
Created December 1, 2011 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveclarke/1412450 to your computer and use it in GitHub Desktop.
Save steveclarke/1412450 to your computer and use it in GitHub Desktop.
jQuery Tips
// When you’re queuing up a chain of animations, you can use the delay()
// method to pause the animation for a length of time; pass that time as
// a parameter in milliseconds.
$('div').hide().delay(2000).show(); // div will stay hidden for 2 seconds before showing.

Useful Plugins

lightBox

fancyBox (free for non-commercial)

Flashembed

Interesting functions to keep in mind

wrap()

replaceAll()

map()

grep()

get()

after() and before()

$(':animated'); // returns all elements currently animating
$(':contains(me)'); // returns all elements with the text 'me'
$(':empty'); // returns all elements with no child nodes or text
$(':parent'); // returns all elements with child nodes or text
$('li:even'); // returns all even-index elements (in this case, <li>s)
$('li:odd'); // can you guess?
$(':header'); // returns all h1 - h6s.
$('li:gt(4)'); // returns all elements with an (zero-based) index greater than the given number
$('li:lt(4)'); // returns all element with an index less than the given number
$(':only-child'); // returns all . . . well, it should be obvious
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment