GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mburakerman/hrjs: 🔄 Tiny JavaScript plugin for highlighting and replacing text in the DOM

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
test
test
 
 
.eslintrc.js
.eslintrc.js
 
 
.gitignore
.gitignore
 
 
License.txt
License.txt
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

HR.js

Tiny JavaScript plugin for highlighting and replacing text in the DOM


NPM NPM License


âŦ Install

npm install hrjs

or use CDN:

<script src="https://unpkg.com/hrjs"></script>

đŸĒĄ Usage

<p id="mytext">Lorem ipsum dolor sit amet.</p>
<script>
  new HR("#mytext", {
    highlight: "dolor",
    replaceWith: "cat",
    backgroundColor: "#B4FFEB"
  }).hr();
</script>

That's it!

CodePen demo

CodePen demo

đŸĒĄ Multiple Keywords example

You can also highlight and replace multiple keywords.

<p id="mytext">I love JavaScript.</p>
<script>
  new HR("#mytext", {
    highlight: ["love","JavaScript"],
    replaceWith: ["like", "jQuery"],
    backgroundColor: "#B4FFEB"
  }).hr();
</script>

CodePen Multiple demo

đŸĒĄ Highlight example

To highlight only, just add your keyword to highlight option.

<p class="mytext">Lorem ipsum dolor sit consectetur amet.</p>
<h3 class="mytext">Consectetur enim ipsam voluptatem quia</h3>
<script>
  new HR(".mytext", {
    highlight: "consectetur",
    backgroundColor: "#B4FFEB"
  }).hr();
</script>

CodePen Highlight demo

✅ Test

Clone project, install dependencies and run npm run test

âš™ī¸ Customize

These are default options.

new HR("elem", {
  highlight: null,
  replaceWith: null,
  backgroundColor: "#FFDE70"
}).hr();

ÂŠī¸ License

Licensed under the MIT License.

About

🔄 Tiny JavaScript plugin for highlighting and replacing text in the DOM

mburakerman.github.io/hrjs/

Topics

domhighlighthighlight-textjavascriptreplace-text

Resources

Readme
MIT license
Activity

Stars

439 stars

Watchers

12 watching

Forks

26 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.