Skip to content

Instantly share code, notes, and snippets.

@jasonkuhrt
Created October 1, 2012 20:05
Show Gist options
  • Save jasonkuhrt/3814100 to your computer and use it in GitHub Desktop.
Save jasonkuhrt/3814100 to your computer and use it in GitHub Desktop.
Helper function to select next sibling or farthest left i.e. parent's first-child (this is helpful for looping galleries, etc.)
jQuery.fn.next-or-first = ->
$next = @next!
if not empty $next then $next else @parent!children!first!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment