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

  • Home
  • SEARCH
  • 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 8756871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:10:23+00:00 2026-06-13T14:10:23+00:00

Currently I am using a Jquery string to try and target a SPECIFIC word

  • 0

Currently I am using a Jquery string to try and target a SPECIFIC word in the entire body of the site and add a class to it. So every single time the word “Nike” appears for example it will make it red and attach a TM to the end of it.

I have been using this but it only replaces the 1st occurrences of the work Nike in the content and I cannot figure out why its not replacing all of them.

Here is the sample: http://jsbin.com/ijufu3/21/

Any ideas?

  • 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-06-13T14:10:24+00:00Added an answer on June 13, 2026 at 2:10 pm

    I’d suggest something along the lines of:

    $('body').html(
        function(i,h){
            return h.replace(/(Nike)/g,'<span class="nike tm">$1</span>');
        });​
    

    Coupled with the following CSS:

    .tm::after {
        content: '™';
    }
    
    .nike {
        color: red;
    }​
    

    JS Fiddle demo.

    Where the selector is amended to whatever elements in which you expect to find the word.

    Given that you may need to target browsers that don’t implement the ::after pseudo-elements/CSS-generated content, then there’s also the option of:

    $('body').html(
        function(i,h){
            return h.replace(/(Nike)/g,'<span class="nike">$1™</span>');
        });​
    

    JS Fiddle demo.

    Which omits adding the tm class and explicitly adds that character to the HTML string returned.

    These approaches work because regular expressions allow for the use of the g (I think ‘global’?) flag, which replaces every occurence of the encountered match (the string within the parentheses). Because you’re looking at the html content, though, this carries the risks that any class-name of nike will itself also be replaced, so be very, very sure that this string will not crop up in unexpected places (where the replacement would cause problems).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using jQuery to make a div clickable and in this div I
I'm currently using JQuery to assign colors to containers. In Chrome and IE, when
I'm currently using jQuery Cookies plugin, and depending on which side of the page
I am currently using jQuery to load a variable php layout depending on the
I am currently using jquery corner for making a div round cornered. But the
I'm currently using this jQuery validate plugin and having an issue in IE where
I am currently using Valums JQuery File Upload plugin. The plugin is very convenient
I'm currently using the jQuery fullcalendar plugin but I've came across an issue regarding
I am very new to web development. I am currently using tablesorter jquery plugin
I'm currently using the following jQuery plugin: jQuery OEmbed. This plugin works great in

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.