GithubHelp home page GithubHelp logo

gingerbeardman / jquery.highlightregex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jbr/jquery.highlightregex

0.0 3.0 0.0 124 KB

jQuery Plugin that lets you highlight document text with a regular expression.

Home Page: http://jbr.github.com/jQuery.highlightRegex

JavaScript 100.00%

jquery.highlightregex's Introduction

jQuery highlightRegex plugin

Want to highlight some text on a page with information you only know in javascript, maybe based on some dynamic input? Check out the highlight v3 by Johann Burkard. Need to be able to do the same thing but with a regular expression? You're at the right place.

Demonstration

Check out a simple demo here (source included in this repository).

Usage

$('#any.jquery.selector').highlightRegex(/[aeiou]/ig);

This would wrap all all vowels inside of #any.jquery.selector with a <span class='highlight'>.

To clear the highlighting, just call $('#any.jquery.selector').highlightRegex(); (with no argument).

If you'd like to wrap with a different sort tag and/or class, use

$('#jquery.selector').highlightRegex( /some ([rR]egex)/, {
  tagType:   'strong',
  className: 'andHale'
});

If you'd like to specify a palette of classes so that each match group is styled differently, use:

$('#jquery.selector').highlightRegex( /some ([rR]egex)/, {
  tagType:   'strong',
  className: 'andHale',
  palette:   ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
});

Note: colours are recycled if there are more match groups than colours.

Additional attributes can be set on the created tag

$('#jquery.selector').highlightRegex( /some ([rR]egex)/, {
  attrs: {'data-color': 'blue'}
});

jquery.highlightregex's People

Contributors

loppear avatar jbr avatar gingerbeardman avatar

Watchers

 avatar James Cloos 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.