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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:17:17+00:00 2026-05-26T12:17:17+00:00

I used jquery live search for live search. I have this html. A list

  • 0

I used jquery live search for live search. I have this html. A list with a lot of names from persons.

<ul id="friends" class="friend-selection">
    <li>
        <a href="#" title="Ik nodig deze vriendin uit">    
            <img src="static/img/voorbeeld/vrouw.jpg" width="50" height="50">
            <span class="name">Janneke Scheerhoorn</span>
        </a>        
    </li>
<ul>
<input type="text" name="q" value="">

Now i used jquery live search function. But i have a problem with this. The live search is is case sensitive. How can i fix the live search script. That this is not case sensitive. Thanks for help. Here you have the script:

Plugin:

(function($) {
  var Search = function(block) {
    this.callbacks = {};
    block(this);
  }

  Search.prototype.all = function(fn) { this.callbacks.all = fn; }
  Search.prototype.reset = function(fn) { this.callbacks.reset = fn; }
  Search.prototype.empty = function(fn) { this.callbacks.empty = fn; }
  Search.prototype.results = function(fn) { this.callbacks.results = fn; }

  function query(selector) {
    if (val = this.val()) {
      return $(selector + ':contains("' + val + '")');;
    } else {
      return false;
    }
  }

  $.fn.search = function search(selector, block) {
    var search = new Search(block);
    var callbacks = search.callbacks;

    function perform() {
      if (result = query.call($(this), selector)) {
        callbacks.all && callbacks.all.call(this, result);
        var method = result.size() > 0 ? 'results' : 'empty';
        return callbacks[method] && callbacks[method].call(this, result);
      } else {
        callbacks.all && callbacks.all.call(this, $(selector));
        return callbacks.reset && callbacks.reset.call(this);
      };
    }

    $(this).live('keypress', perform);
    $(this).live('keydown', perform);
    $(this).live('keyup', perform);
    $(this).bind('blur', perform);
  }
})(jQuery);

In the html i used this:

(function($) {
        $(document).ready(function() {
          $('input[name="q"]').search('#friends li', function(on) {
            on.all(function(results) {
              var size = results ? results.size() : 0
              $('#count').text(size + ' results');
            });

            on.reset(function() {
              $('#none').hide();
              $('#friends li').show();
            });

            on.empty(function() {
              $('#none').show();
              $('#friends li').hide();
            });

            on.results(function(results) {
              $('#none').hide();
              $('#friends li').hide();
              results.show();
            });
          });
        });
      })(jQuery);
  • 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-26T12:17:17+00:00Added an answer on May 26, 2026 at 12:17 pm

    So here is the final script edited with the case unsensitive ‘Contains’ method. Please note that I changed ‘contains’ to ‘Contains’ within the function ‘query’:

    (function($) {
        var Search = function(block) {
            this.callbacks = {};
            block(this);
        }
    
        Search.prototype.all = function(fn) { this.callbacks.all = fn; }
        Search.prototype.reset = function(fn) { this.callbacks.reset = fn; }
        Search.prototype.empty = function(fn) { this.callbacks.empty = fn; }
        Search.prototype.results = function(fn) { this.callbacks.results = fn; }
    
        jQuery.expr[':'].Contains = function(element,i,m){
            return (element.textContent || element.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
        }; 
    
        function query(selector) {
            if (val = this.val()) {
                return $(selector + ':Contains("' + val + '")');;
            } else {
                return false;
            }
        }
    
        $.fn.search = function search(selector, block) {
            var search = new Search(block);
            var callbacks = search.callbacks;
    
            function perform() {
                if (result = query.call($(this), selector)) {
                    callbacks.all && callbacks.all.call(this, result);
                    var method = result.size() > 0 ? 'results' : 'empty';
                    return callbacks[method] && callbacks[method].call(this, result);
                } else {
                    callbacks.all && callbacks.all.call(this, $(selector));
                    return callbacks.reset && callbacks.reset.call(this);
                };
            }
    
            $(this).live('keypress', perform);
            $(this).live('keydown', perform);
            $(this).live('keyup', perform);
            $(this).bind('blur', perform);
        }
    })(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have html elements with class ajaxem that are ment to be used in
this problem is so weird. i have used jquery to link a specific id
I have a livesearch and it uses an unordered list, like this: <input id=search/>
Has anyone used jQuery to populate an autocomplete list on a textbox using ASP.NET
I have used JQuery for a small animation work: a table #photos contains 9
I have not used jquery much yet and not very familiar with it. Trying
my actual problem is that .live() jQuery method is not working. This si the
I have a jquery dialog box that is used to edit and update a
I have used the script at: http://www.javascript-coder.com/ i use the following jquery code in
I have search the previous question but couldn't find the answer. Dynamically generated html:

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.