Skip to content

Instantly share code, notes, and snippets.

@enopanen
Created December 3, 2013 18:07
Show Gist options
  • Select an option

  • Save enopanen/7774328 to your computer and use it in GitHub Desktop.

Select an option

Save enopanen/7774328 to your computer and use it in GitHub Desktop.
This idea of traversing through object nodes is deep enough to be an article within itself. But for any intermediate or advance jQuery developers who understand this topic, I’m sure these quick snippets will help in future problem solving. The goal is often to pull data from another element related to the currently active element(clicked, hovere…
$("div#home").prev("div"); // find the div previous in relation to the current div
$("div#home").next("ul"); // find the next ul element after the current div
$("div#home").parent(); // returns the parent container element of the current div
$("div#home").children("p"); // returns only the paragraphs found inside the current div
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment