#278 closed enhancement (worksforme)
Make :contains() be optionally case insensitive
Reported by: | yehuda | Owned by: | |
---|---|---|---|
Priority: | trivial | Milestone: | |
Component: | core | Version: | |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
At the moment, :contains() is case sensitive only.
We need a way to make it optionally case insensitive.
Change History (10)
comment:1 Changed 16 years ago by
Priority: | major → trivial |
---|---|
Type: | bug → enhancement |
comment:2 follow-up: 3 Changed 16 years ago by
Milestone: | 1.0 |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
Version: | 1.0 |
comment:3 Changed 14 years ago by
If anybody's looking for a tested version of the above:
jQuery.extend(jQuery.expr[':'], { "contains-ic": "jQuery.fn.text.apply([a]).toLowerCase().indexOf(m[3].toLowerCase())>=0", });
comment:4 Changed 14 years ago by
Thanks weaverryan, however I had an error with this code in Internet Explorer until i removed the extra comma from the second line:
CHANGE:
jQuery.extend(jQuery.expr:?, {
"contains-ic": "jQuery.fn.text.apply([a]).toLowerCase().indexOf(m[3].toLowerCase())>=0",
});
TO:
jQuery.extend(jQuery.expr:?, {
"contains-ic": "jQuery.fn.text.apply([a]).toLowerCase().indexOf(m[3].toLowerCase())>=0"
});
Works like a charm now!
comment:6 follow-up: 7 Changed 13 years ago by
Replying to mike123: could someone please del. this spam?
@thewiredmous : Firefox gives me a "X is not defined in jquery-1.3.2.js"
comment:7 Changed 13 years ago by
comment:10 Changed 10 years ago by
Description: | modified (diff) |
---|
In addition to the one mentioned above, there is one (icontains
) in the docs for Sizzle:
https://github.com/jquery/sizzle/wiki/Sizzle-Documentation
As far as changing the default, forget it. That would break code. The tools are right here for meeting your needs, they don't need to be in core for you to use them.
comment:11 Changed 9 years ago by
I appreciate that :contains() cannot be changed to case-insensitive by default because it would break existing code. However, it's unacceptable to make the user search the Internet to find the workaround mentioned in this ticket. Please add a :containsIgnoreCase() selector to base jQuery. It's silly that it doesn't have this already.
This could easily be added when required:
$.extend($.expr:?, {
});
Untested, but pretty simple.