if statement - Non-case-sensitive comparison of text input value with JQuery -


i have looked through answers relating writing custom selectors in jquery (such one: writing jquery selector case-insensitive version) still unclear on if custom selector best approach problem.

i want take input text box , compare list of known terms. want comparison case insensitive. here trying 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 jsfiddle: http://jsfiddle.net/xcbmq/

i want "kittens" , "kittens" , "kittens" match kitten condition. not clear custom selector best way this, or if can use .is() or similar. if custom selector best way it, how/where integrate code?

update:

here jsfiddle working code, dystroy: http://jsfiddle.net/xcbmq/2/

you can do

if ($("#query").val().tolowercase() == "kittens") { 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -