Git Product home page Git Product logo

jquery.highlightregex's Introduction

⚠ Notice ⚠

I extracted this library from a project in 2009. It did everything I needed it to, and maybe it helped a few people. I no longer personally recommend building websites using the DOM as data like jQuery does. Newer alternatives to this library exist, although this still serves its intended function. This repo is partially maintained in that pull requests will be reviewed and bugs will be fixed, but I'm unlikely to add new behavior.

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).

Bower Installation

`bower install jquery-highlightRegex --save`

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'
});

Additional attributes can be set on the created tag

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

jquery.highlightregex's People

Contributors

jbr avatar nfriedly avatar loppear avatar albert-gonzalez avatar jc00ke avatar shawnstrickland 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.