tags:

views:

4364

answers:

2

I am trying to find if an image has in its source name "noPic" which can be in upper or lower case.

var noPic = largeSrc.indexOf("nopic");

should i write

var noPic = largeSrc.toLowerCase().indexOf("nopic");

It doesn't work

+3  A: 

No, there is no case-insensitive way to call that function. Perhaps the reason your second example doesn't work is because you are missing a call to the text() function.

Try this:

var noPic = largeSrc.text().toLowerCase().indexOf("nopic");
Andrew Hare
+4  A: 

You can use regex with a case-insensitive modifier - admittedly not necessarily as fast as indexOf.

var noPic = largeSrc.search(/nopic/i);
jharlap