Couple of jQuery selectors

Haven’t had much interesting stuff to do this week so I figured I’d post some jquery selectors I’ve been using for other projects. The first one I found online some time ago and don’t remember who originally made it, the second is one of my own creation.

Case Insensitive Contains

Snipplr: http://snipplr.com/view/54884/case-insensitive-contains-jquery-selector/

This one was not created by me, but I can’t remember who originally created it. It does the same thing as the built in :contains() selector with one important difference, it’s case insensitive. Since I usually type in all lower case (bad habit I know) I like to use it for filters. It’s also a nice one to use on name filters, that way if the person using the filter doesn’t use the proper case it will still pull of the name, for example if they type in “Delsoto”, but the proper capitalization is “DelSoto” the default :contains() won’t find it, but this modified :Contains() will. Very convient.

Is

Snipplr: http://snipplr.com/view/54885/jquery-is-selector/

This is a simple one I created to be a more accurate varient of the :contains() selector. This will select everything where the contents is exactly what you tell it. It was originally created for a game platform drop-down selector where contains was pulling to many results, for example there are 4 sony system, all with very similar names; Playstation, Playstation 2, Playstation 3, and Playstation Portable. If you use :contains() for “Playstation” you’ll pull all four system. This new :is() selector fixes this and is much faster than looping through a list and comparing them one-by-one.

If you have any questions about these, or happen to know who made that nifty case insensitive one, post and let me know. Use it in a cool project, do the same.

Leave a Reply

Your email address will not be published. Required fields are marked *