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 9226305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:47:51+00:00 2026-06-18T04:47:51+00:00

I am using http://loopj.com/jquery-tokeninput/demo.html#formatting I would like to make the matching chars also red,

  • 0

I am using http://loopj.com/jquery-tokeninput/demo.html#formatting

I would like to make the matching chars also red, but cannot locate the piece of CSS or Javascript they have.

enter image description here

Their project is on GitHub.

  • 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-18T04:47:52+00:00Added an answer on June 18, 2026 at 4:47 am

    Using chrome developer tools I found out that jquery-tokeninput is formatting search results like the following:

    <ul style="display: block; overflow: hidden;">
        <li class="token-input-dropdown-item2-facebook">Trad<b>in</b>g Spouses</li>
        <li class="token-input-dropdown-item-facebook">T<b>in</b> Man</li>
    </ul>
    

    So it is not using a css class to highlight the matching chars, it is doing it manually putting those chars inside a <b> tag. After a quick search in the javascript source file I was able to find this function:

    // Highlight the query part of the search term
    function highlight_term(value, term) {
        return value.replace(
          new RegExp(
            "(?![^&;]+;)(?!<[^<>]*)(" + regexp_escape(term) + ")(?![^<>]*>)(?![^&;]+;)",
            "gi"
          ), function(match, p1) {
            return "<b>" + escapeHTML(p1) + "</b>";
          }
        );
    }
    

    Hence, I guess it is only a matter of modifying it to be able to customize the matching chars style. For instance, you could change the returning string to:

    return '<b class="match">' + escapeHTML(p1) + '</b>';
    

    And apply your styles to the b.match css class.

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

Sidebar

Related Questions

I am using Jquery tokenizer as like facebook using the following plugin http://loopj.com/jquery-tokeninput/ which
I am using tokeninput jquery for autocomplete with asp.net. http://loopj.com/jquery-tokeninput/ i have one textbox
I'm using jQuery Tokenizer ( http://loopj.com/jquery-tokeninput/ ) and am trying to add placeholder text
So I am using the JQuery.datePicker example... http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerStartEnd.html I had the Jquery calendar working
I'm using this plugin: http://loopj.com/jquery-tokeninput/ to do a suggestion field, where the user can
I'm using the plugin found at http://loopj.com/jquery-tokeninput/ in a field which creates a list
I'm a bit of a jQuery newbie, only recently started. I am using http://flesler.blogspot.com.au/2007/10/jqueryscrollto.html
Tokenizer: http://loopj.com/jquery-tokeninput/ shows a hint Type in search term when the user focuses on
im following the railscasts using jquery tokeninput http://railscasts.com/episodes/258-token-fields-revised in creating autocomplete tag tokens and
I am using the $.grep() function http://docs.jquery.com/Utilities/jQuery.grep $.each($.grep( [0,1,2], function(n,i){ return n > 1;

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.