[jQuery] Best way to iterate over a string (each character)
Hello, I am trying to do a simple thing in JQuery, and found some
different ways to make it work. Altough all of them behave identically
and correct in Firefox & Safari, few works in IE.
Which of them you consider the "correct way", OR
Was ths supposed to work OK on IE too?
Thank you
PS: in the case you were wondering, I was not using "console.log" on
IE
$(function() {
texto = 'persona non grata';
$.each(texto, function() {
console.log($(this)[0]);
});
})
$(function() {
texto = 'persona non grata';
$.each(texto, function() {
console.log(this[0]);
});
})
$(function() {
texto = 'persona non grata';
$.each(texto, function(i, nome) {
console.log(nome);
});
})
$(function() {
texto = 'persona non grata';
$.each(texto.split(''), function(i, nome) {
console.log(nome);
});
})