Hello! I need to find the index of the character in the string. There is an indexOf function that is ideal, but it does not work in ie7 .

What other options are there? (will go to jquery too)


    1 answer 1

    In the cycle walk:

     function indexOf(str, target){ for(var i= 0, l = str.length; i<l; i++){ if(str[i] === target){ return i; } } return -1; } 

    Use jQuery.inArray ()

     $.inArray(target, str); 

    Use Underscore _.indexOf

     _.indexOf(str.split(''), target)