Giter VIP home page Giter VIP logo

jquery-highlighter's Introduction

Description

jQuery Highlighter is a key words highlight plugin for jQuery.
Online test page: http://xujinnet.github.com/jQuery-Highlighter/jQuery-Highlighter-Test-Page.html

Main Futures

  1. Support for multiple keywords.
  2. Can overlap between multiple keywords.
  3. Can cancel the highlighted keywords.

Quick Start

  1. Include jQuery and the Highlighter plugin script file in your HTML page:

     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
     <script type="text/javascript" src="jquery.highlighter-1.0.0.min.js"></script>
    
  2. In your HTML body create a container tag pair that will hold some text.Give it an id or class attribute (e.g. "News-Pagination"). This attribute can used as the selector for jQuery.

  3. Write some text into the previously created container tag, that contain the key words you want to search .

  4. Write the JavaScript code in your HTML head:

     <script type="text/javascript">
         // Some key words that within the previously created container tag.
         // Use one space to separate multiple keywords.
     	var someKeyWords = "......";
     	$("#div_Text").highlight(someKeyWords);
     </script>
    
  5. Use your favorite browser to view this page, you will see the keywords are marked red.

  6. If you want to cancel the highlighted keywords or need to highlight keywords several times within the same container tag:

     // Highlight key words.
     // Note the second argument.
     $("#div_Text").highlight(someKeyWords, {needUnhighlight: true});
     
     // Cancel the highlighted keywords.
     $("#div_Text").unhighlight();
    

Available Options

The following list describes what options you have for the second argument of the method "highlight" (option object):

hClass
Specifies the CSS class used to highlight key words.
Data Type: String
Default Value: null

hColor
Specifies the color used to highlight key words. If you setted the hClass option, this option will be ignored.
Data Type: String
Default Value: "#C03"

separator
The symbol used to separate multiple keywords.
Data Type: String
Default Value: " "

wrapper
Specifies the HTML tag used to wrap the keywords.
Data Type: String
Default Value: "em"

useDefaultStyle
When not set hClass option, specify whether to use the default style to highlight the keywords (eg: use the hColor option).
Data Type: Boolean
Default Value: true

needUnhighlight
Specifies whether need the function of cancel the highlighted keywords or highlight keywords several times within the same container tag.
Data Type: Boolean
Default Value: false

License

This plugin is licensed under the CDDL v1.0. You can find the full license text here: http://www.opensource.org/licenses/cddl1.txt.

Contact Information

E-Mail: [email protected]
QQ: 22492791

jquery-highlighter's People

Watchers

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