I need to check if there is a specific piece within a snippet of a word in javascript.
Example, my word is John, I need to check if Jo contains it.
I tried to do with indexOf but it did not work, but it did not work.
//pesquiso tudo que tem dentro dessa classe
$(".form-group").find('*').each(function() {
var cont = 0;
//pego todos os ids
var id = $(this).attr("id");
//verifico se o trecho especifico contem o que eu preciso
if (id.match("txtOutrosNomes") != -1) {
console.log(cont++);
}
});
How to make this comparison?