A Pure-JavaScript, CSS selector engine designed to be easily select DOM-Elements.
To include Quanter in Node, first install with npm.
npm install quanter
Clone a copy of the main Sizzle git repo by running:
git clone git://github.com/jqrony/quanter.git
In the quanter/dist
folder you will find build version of sizzle along with the minified copy and associated map file.
Below are some of the most common ways to include Quanter.
<script src="https://cdn.jsdelivr.net/npm/quanter@4.0.0/dist/quanter.min.js"></script>
There are several ways to use Webpack, Browserify or Babel. For more information on using these tools, please refer to the corresponding project's documentation. In the script, including Quanter will usually look like this:
import quanter from "quanter";
The Quanter
method allows for flexible element selection using a wide range of selector types:
-
✅ CSS Selectors
Supports tag names, class selectors (.class
), ID selectors (#id
), attribute selectors ([attr=value]
), and pseudo-classes (like:nth-child
,:first-of-type
, etc.). -
⚠️ Limited XPath Support
Basic XPath expressions are supported, but with limited syntax recognition. Use only for simple XPath needs.
Best Use: When your use case involves a mix of CSS-style selectors and simple XPath, and you want to avoid switching methods.
Quanter.XPathSelect(String expr, DOMNode context, Array results, Array seed);
selector
[required] A CSS Selector or XPath Expression (comma separated or non-comma separated)context
[optional] An element, document, or document fragment to use as the context for finding elements.results
[optional] An optional array to which the matched elements will be added.seed
[optional] A set of elements to match against
Learn for more documentation
The XPathSelect
method is a specialized function built to handle full XPath syntax, offering complete support for:
- Complex queries
- Nested expressions
- Axes like
following-sibling
,ancestor
,descendant
- Functions like
contains()
,starts-with()
,text()
, etc.
Best Use: When your use case requires powerful and deeply nested element queries using the full capabilities of XPath.
Quanter.XPathSelect(String expr, DOMNode context, Array results, Array seed);
expr
[required] A XPath Expression (comma separated or non-comma separated)context
[optional] An element, document, or document fragment to use as the context for finding elements.results
[optional] An optional array to which the matched elements will be added.seed
[optional] A set of elements to match against
Learn for more documentation