Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 387253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:39:19+00:00 2026-05-12T15:39:19+00:00

Unusual situation. I have a client, let’s call them BuyNow. They would like for

  • 0

Unusual situation. I have a client, let’s call them “BuyNow.” They would like for every instance of their name throughout the copy of their site to be stylized like “BuyNow,” where the second half of their name is in bold.

I’d really hate to spend a day adding <strong> tags to all the copy. Is there a good way to do this using jQuery?

I’ve seen the highlight plugin for jQuery and it’s very close, but I need to bold just the second half of that word.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:39:20+00:00Added an answer on May 12, 2026 at 3:39 pm

    To do it reliably you’d have to iterate over each element in the document looking for text nodes, and searching for text in those. (This is what the plugin noted in the question does.)

    Here’s a plain JavaScript/DOM one that allows a RegExp pattern to match. jQuery doesn’t really give you much help here since selectors can only select elements, and the ‘:contains’ selector is recursive so not too useful to us.

    // Find text in descendents of an element, in reverse document order
    // pattern must be a regexp with global flag
    //
    function findText(element, pattern, callback) {
        for (var childi= element.childNodes.length; childi-->0;) {
            var child= element.childNodes[childi];
            if (child.nodeType==1) {
                findText(child, pattern, callback);
            } else if (child.nodeType==3) {
                var matches= [];
                var match;
                while (match= pattern.exec(child.data))
                    matches.push(match);
                for (var i= matches.length; i-->0;)
                    callback.call(window, child, matches[i]);
            }
        }
    }
    
    findText(document.body, /\bBuyNow\b/g, function(node, match) {
        var span= document.createElement('span');
        span.className= 'highlight';
        node.splitText(match.index+6);
        span.appendChild(node.splitText(match.index+3));
        node.parentNode.insertBefore(span, node.nextSibling);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a slightly unusual situation where I'm needing to maintain CLIENT tcp connections
I have an unusual situation to model in a MS SQL Server database: the
I have an unusual situation - I have an embedded video streaming device with
I have a very unusual situation that I am hoping someone will be able
In my current situation, it is not unusual for me to have several UNIX
I am faced with rather unusual situation I will have url in any of
I have an unusual situation where I need to add an arbitrary classpath entry
I've got an unusual situation: I'm using a Linux system in an embedded situation
I have a bit of an unusual question. I'm running an old DOS game
Here's my particular situation... I have a decent amount of experience with webforms, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.