dom-search
Install
npm install --save dom-search
Usage
const domSearch = ;//Alternatively with es2015//import domSearch from 'dom-search'const div = ; console;console;consoleconsole { const div = document; const p1 = document; const p2 = document; p1innerHTML = 'This is one paragraph.'; p2innerHTML = 'This is also a paragraph.'; div; div; return div;}
API
domSearch(node, pattern, options) -> result
node
is any dom node with text children.
pattern
can be string, or regexp to search with.
result
is an array of objects with two fields:
- textNode (the text node the pattern matched)
- parent (the parent of the matching text node)
options.all
Set if all occurrences of the pattern should be matched.
The default is false
which means the pattern will only be matched once.
About
dom-search is a nice way to find a node, or two that have a text node that contains a certain pattern amongst the text node children of an element.
Use browserify with this module, or some other transpiler.