thanks for the tip. That should take care of my issue without the additional "c=c||mask.chatAt(i);" lines.
<div><span class="gmail_quote">On 10/3/07, <b class="gmail_sendername">Brandon Aaron</b> <
<a href="mailto:brandon.aaron@gmail.com">
brandon.aaron@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">You could just force it into an array before passing it to each using the split method.
var str = "abcd";
$.each( str.split(""), fn );
--
<span class="sg">Brandon Aaron</span><div><span class="e" id="q_11567b296a35ec49_2">
<span>
</span>
<div><span class="gmail_quote">On 10/3/07, <b class="gmail_sendername">Josh Bush</b> <<a href="mailto:josh.bush@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
josh.bush@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It was all a big tease. I was happy when I saw this work in FF, only
to be let down in IE. Dang you Internet Explorer and your crazy
ways! Argh.
As a side note, would this be worth including in the core, or am I the
only person in the world to need this?
A change to lines 584 and 585 would cover this
from:
for ( var i = 0, ol = obj.length, val = obj[0];
i < ol && fn.call(val,i,val) !== false; val = obj[++i] ){}
to:
for ( var i = 0, ol = obj.length, val = obj[0]||obj.charAt(0);
i < ol && fn.call(val,i,val) !== false; val = obj[++i]||obj.charAt(i) )
{}
Just a thought...
Josh
On Oct 3, 11:17 am, Flesler <
<a href="mailto:afles...@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
afles...@gmail.com</a>> wrote:
> The reason is the one you said, FF treats string as array-like
> elements. While IE doesn't (I wonder why, if they are actually arrays
> of chars)..
> Anyway, I don't think $.each is meant to iterate over strings, only
> objects and array-like. I think the "... it could be a String or a
> Number..." in the API (<a href="http://jquery.com/api" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
jquery.com/api</a>) is quite confusing in this
> case.
>
> Ariel Flesler
>
> On Oct 2, 9:57 pm, Josh Bush <<a href="mailto:josh.b...@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
josh.b...@gmail.com</a>> wrote:
>
> > I found out something interesting tonight. I learned that $.each on a
> > string produces an undefined character:
> > $.each( mask, function(i,c){
> > //in IE c is undefined, but in other browsers it's actually a
> > character
>
> > });
>
> > I'm guessing it's because IE won't allow mask[i] but only
> > mask.charAt(i). Was $.each intended to loop over strings?
>
> > I'm not sure if it's a bug, so I just thought I'd point this out. My
> > fix was to say "c=c||mask.charAt(i);" immediately inside of my loop
> > function. I also noticed similar behavior in $.map over a string.
>
> > Thanks
> > Josh
> > <a href="http://digitalbush.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">digitalbush.com</a>
</blockquote></div>
</span></div></blockquote></div>