I have looked through the answers relating to writing custom selectors in JQuery (such as this one: Writing jQuery selector case-insensitive version) but am still unclear on if a custom selector is the best approach to my problem.
I want to take input from a text box and compare it to a list of known terms. I want the comparison to be case insensitive. Here is what I am trying to do:
$('#query').change(function() { if ($("#query").val() == "kittens") { $('#change').text("kittens") } else if ($("#query").val() == "puppies") { $('#change').text("puppies") } else { $('#change').text("neither kittens nor puppies") } }); Here is a JSFiddle: http://jsfiddle.net/XcbMQ/
I want "kittens" and "Kittens" and "KITTENS" to all match the kitten condition. I am not clear that a custom selector is the best way to do this, or if I can use .is() or similar. If a custom selector is the best way to do it, how/where do I integrate that into my code?
UPDATE:
Here is a JSFiddle with the working code, thanks to dystroy: http://jsfiddle.net/XcbMQ/2/