Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cburschka/jquery-replacetext
Replace substrings inside DOM nodes with text or new nodes.
https://github.com/cburschka/jquery-replacetext
Last synced: 9 days ago
JSON representation
Replace substrings inside DOM nodes with text or new nodes.
- Host: GitHub
- URL: https://github.com/cburschka/jquery-replacetext
- Owner: cburschka
- License: mit
- Created: 2015-05-20T06:26:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-04T23:04:48.000Z (over 8 years ago)
- Last Synced: 2025-01-21T21:36:20.736Z (20 days ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# jQuery replaceText
This jQuery plugin searches the text-node children of all elements in a jQuery
object, and replaces matched substrings with new content. The new content can
either be text or DOM nodes.## Usage
### .replaceText( search, replace );
#### search
Type: **String** or **RegExp**
What to search for.
#### replace
Type: **String** or **Element** or **Array** or **jQuery**
The content that will be inserted in place of the matched substrings. A **String**
value will be inserted in the text node; any other content will split the text node
and be inserted between the parts.Note: HTML code in a **String** argument is not evaluated.
### .replaceText( search, function );
#### search
Type: **String** or **RegExp**
What to search for.
#### function
Type: **Function**( **String** match1, ... , **String** matchN ) =>
(**String** or **Element** or **Array** or **jQuery**)A function that returns the replacement value, which is interpreted in the same
way as a static replacement value.If the search argument is a **RegExp** with parenthesized groups, then the
function will receive these groups as arguments.Note: The full substring match is *not* included unless the entire regular
expression is parenthesized.