Git Product home page Git Product logo

jquery.text.highlight's Introduction

jQuery Text Highlight

jQuery Text Highlight is a plugin for highlighting Words, Text or Regular Expressions within the DOM.

Feature requests are welcome.

Usage Examples

Given the following html:

<h1>Hello World</h1>
$('h1').textHighlight('Hello');
$('h1').textHighlight(/World/);
$('h1').textHighlight([/Hello/, 'World']);
$('h1').textHighlight(['Hello', 'World'], {
  element: 'mark',
  class: '',
  caseSensitive: false
});
$('h1').removeHighlight();

Each line will produce the corresponding markup:

<h1>
  <mark>Hello</mark>
  World
</h1>
<h1>
  Hello
  <mark>World</mark>
</h1>
<h1>
  <mark>Hello</mark>
  <mark>World</mark>
</h1>
<h1>
  <mark>Hello</mark>
  <mark>World</mark>
</h1>

Methods

$.fn.textHighlight( term, options )

Encapsulates text within a specified element.

  • term could be either a string, a regular expression or an array of both.
  • options is an object containing configuration options. See below for more details.
$.fn.removeHighlight();

Removes the encapsulation applied by $.fn.textHighlight.

Options

Option Type Description
element object The tag name in which the matched text should be encapsulated.
class string A specific class to be added to that element.
caseSensitive boolean Whether to ignore the case of the specified keyword/regex.
ignore selector A selector that specifies a subset of elements that should be ignored.

Note: The caseSensitive option overrides the i flag of Regular Expressions.

License

This plugin and the associated documentation are distributed under the terms of the MIT License. See COPYING for more details.

jquery.text.highlight's People

Contributors

itay-grudev avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.