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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:49:38+00:00 2026-06-09T11:49:38+00:00

here is my code that works very fine. Found it on a website and

  • 0

here is my code that works very fine. Found it on a website and modified a little bit.

<script>
(function ($) {
// custom css expression for a case-insensitive contains()
jQuery.expr[':'].Contains = function(a,i,m){
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
};
function listFilter(header, list) { // header is any element, list is an unordered list
// create and add the filter form to the header
var form = $("<form>").attr({"class":"filterform","action":"#"}),
input = $("<input>").attr({"class":"filterinput","type":"text", "value":"Filterfunktion"});
$(form).append(input).appendTo(header);
$(input)
.change( function () {
var filter = $(this).val();


if(filter) {
// this finds all links in a list that contain the input,
// and hide the ones not containing the input while showing the ones that do
$(list).find("a:not(:Contains(" + filter + "))").parent().fadeOut();
$(list).find("a:Contains(" + filter + ")").parent().fadeIn();
} else {
$(list).find("li").slideDown();
}
return false;
})
.keyup( function () {
// fire the above change event after every letter
$(this).change();
});
}
//ondomready
$(function () {
listFilter($(".filter"), $(".list"));
});

$(function() {
    $(".filterinput").focus(function() {
      $(this).val('')

      });
 });

}(jQuery));
</script>

But the one thing that I cant get to work, is that the script should find/match a string when its with a whitespace and i type ist without a whitespace.

For exmpale:

I have < li>DCB 112

. When I now type “DCB 112” in my inputfield it filter that correctly and show me that. But when I type “DCB112” the script cant match this and show me nothing. Is there a solution possible?

Greetings from Poland!

  • 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-09T11:49:40+00:00Added an answer on June 9, 2026 at 11:49 am

    Ok, maybe a bit twisted, but what I would do is taking all the links of the list and iterate over them, removing every whitespace of its text, and checking if the text you are looking for is in it. Something like this:

    var filter = $(this).val().replace(/\s+/g, '').toLowerCase();
    
    // I'm omitting loads of code...
    var text;
    var index;
    $(list).find('a').each(function(i, el){
        text = $(el).text().replace(/\s+/g, '').toLowerCase();
        index = text.indexOf(filter);
        if(index != -1){
            // The substring is contained -> show parent
        }else{
            // The substring is not contained -> hide parent
        }
    });
    

    Hope it helps and it works, as I didn’t tested it :/

    EDIT:

    Tested and working 🙂

    http://jsfiddle.net/QVkuP/

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

Sidebar

Related Questions

I have a little bit of Javascript that almost works correctly. Here's the code:
Site here . Why is it that the code works for $('#club').change(function(event) but not
I have very similar multithreaded code elsewhere in my codebase that works fine, but
I've got some code here that works great on IPv4 machines, but on our
Here is a code excerpt from AspComet project that works with Autofac. public MessageBus(IClientRepository
I cannot get this to work, here is code that I found in another
Here is my current code (that i am very proud of for my first
Here is the code that doesn't work: Enemy.strength = srand((unsigned)time(NULL)) % 10; Enemy.strength is
I have a piece of code here that does not work despite me using
There is a weird code here that I need to make work.. can you

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.