JQuerySelector
JQuerySelector
class is used for finding DOM elements using jQuery selector mechanism. jQuery uses Sizzle as its search engine (which you can use directly by using SizzleSelector
), however it also contains additional features like traversing methods that Sizzle itself does not support.
Constuctor
Initializes a new instance of the JQuerySelector
class.
The basic constructor with the selector string as an argument.
var selector = new JQuerySelector(":text");
Add
Adds elements to the set of matched elements.
var selector = new JQuerySelector("div").Add("p");
AddBack
Add the previous set of elements on the stack to the current set, optionally filtered by a selector.
var selector = new JQuerySelector("div").Find("span").AddBack();
AndSelf
Add the previous set of elements on the stack to the current set.
var selector = new JQuerySelector("div").Find("span").AndSelf();
Children
Get the children of each element in the set of matched elements, optionally filtered by a selector.
var selector = new JQuerySelector("div").Children("span");
Closest
For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
var selector = new JQuerySelector("div").Closest("article");
Contents
Get the children of each element in the set of matched elements, including text and comment nodes.
var selector = new JQuerySelector("div").Contents();
End
End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.
var selector = new JQuerySelector("div").Filter(".class").End();
Eq
Reduce the set of matched elements to the one at the specified index.
var selector = new JQuerySelector("div").Eq(3);
Filter
Reduce the set of matched elements to those that match the selector or pass the function's test.
var selector = new JQuerySelector("div").Filter(".class");
Find
Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
var selector = new JQuerySelector("div").Find(".class");
First
Reduce the set of matched elements to the first in the set.
var selector = new JQuerySelector("div").First();
Has
Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
var selector = new JQuerySelector("div").Has("span");
Is
Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
var selector = new JQuerySelector("div").Is(".class");
Last
Reduce the set of matched elements to the final one in the set.
var selector = new JQuerySelector("div").Last();
Next
Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
var selector = new JQuerySelector("div").Next("div");
NextAll
Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.
var selector = new JQuerySelector("div").NextAll("div");
NextUntil
Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed.
var selector = new JQuerySelector("div").NextUntil(".class");
Not
Remove elements from the set of matched elements.
var selector = new JQuerySelector("div").Not(".class");
OffsetParent
Get the closest ancestor element that is positioned.
var selector = new JQuerySelector("div").OffsetParent();
Parent
Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
var selector = new JQuerySelector("div").Parent();
Parents
Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
var selector = new JQuerySelector("div").Parents();
ParentsUntil
Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object.
var selector = new JQuerySelector("div").ParentsUntil("body");
Prev
Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.
var selector = new JQuerySelector("div").Prev("div");
PrevAll
Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
var selector = new JQuerySelector("div").PrevAll("div");
PrevUntil
Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object.
var selector = new JQuerySelector("div").PrevUntil(".class");
Siblings
Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
var selector = new JQuerySelector("div").Siblings();
Slice
Reduce the set of matched elements to a subset specified by a range of indexes.
var selector = new JQuerySelector("div").Slice(1, 3);
Last updated
Was this helpful?