Bug Tracker

Error: Failed to load processor NavWiki
No macro or processor named 'NavWiki' found

This code is part of the the jQuery Base? module.

DOM Traversing

Also refer to:

  • Basic Expressions, basic ways to access DOM elements with jQuery
  • XPath - Access DOM elements with XPath expressions.
  • CSS - Access DOM elements via CSS selectors.
  • Custom expressions - A number of useful custom functions to select DOM elements, including all odd, even, parent, first, last, elements containing text, etc.

find(Expression)

Error: Failed to load processor param
No macro or processor named 'param' found

Description

This looks for more elements within the context of all matched elements. In CSS-speak, the below is the same as doing: "p a".

Examples

  $("p").find("a").css("fontWeight","bold");

end()

Description

The purpose of this function is to end the current find() and revert back to the last time either find() or $() was called. The main advantage that this has is the ability to do multiple finds.

Examples

  $("p")
    .find("a")
      .css("fontWeight","bold")
    .end()
    .find("img")
      .hide()
    .end();

The above code finds all the paragraphs, then finds all the A tags, makes them bold, then finds all the IMG tags (within all the paragraphs) and hides them.

filter(Expression)

Error: Failed to load processor param
No macro or processor named 'param' found

Description

The difference between find and filter is an important one: find locates all child elements that match the specified expression, filter removes any elements (from the current set of matched elements) that do not match the expression.

Examples

  $("p").filter(".ohmy");

The above code finds all paragraph elements and then removes any of the matched elements which do not have an ohmy class.

not(Expression)

Error: Failed to load processor param
No macro or processor named 'param' found

Description

When you pass an Expression to the not function, it does the exact opposite of filter--in that it only keeps the elements that do not match the expresion.

Examples

  $("p").not(".ohmy");

The above would only return the paragraphs which do not have an ohmy class.

not(DOMElement)

Error: Failed to load processor param
No macro or processor named 'param' found

This removes the specified DOMElement from the list of matched elements. Does not complain if the element is already not in the list.

  // Bad example, but you get the idea
  $("p").not( document.getElementById("test") );

add(Expression OR Array OR DOMElement)

Error: Failed to load processor param
No macro or processor named 'param' found

Description

This method adds the DOMElement, or the array of DOMElements onto the list of matched elements. If a String is provided, the String is interpreted as an expression, and those elements are added to the list.

Examples

  $("p").add("div");

The above is the combination of all paragraph and div elements, which is the same as:

  $("p,div")