Highlight matched word partials in a given element.
- Source:
- To do:
-
- Add a function for restoring the previous text.
- Accept mappings for converting shortcuts like WP: to Wikipedia:.
Methods
$.fn.highlightText(matchString, [options]) → {jQuery}static
#
Highlight certain text in current nodes (by wrapping it in <span class="highlight">...</span>
).
To use this jQuery
plugin, load the jquery.highlightText
module with mw.loader
.
Example
mw.loader.using( 'jquery.highlightText' ).then( () => {
// no styling is provided by default.
mw.util.addCSS( `.highlight { background: yellow; }` )
$( '#bodyContent' ).highlightText( 'bear' );
} );
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
matchString |
string | String to match |
|||||||||||
options |
Object |
optional |
Properties:
|
- Source:
Returns:
- Type
- jQuery
Highlight certain text in current nodes (by wrapping it in
<span class="highlight">...</span>
).