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
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
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");
You can use regex with a case-insensitive modifier - admittedly not necessarily as fast as indexOf.
var noPic = largeSrc.search(/nopic/i);