On Tue, Dec 22, 2009 at 10:40 AM, Charlie Griefer <charlie.grie...@gmail.com
> wrote:

> On Tue, Dec 22, 2009 at 10:34 AM, Mike Walsh <mike_wa...@mindspring.com>wrote:
>
>>
>> [ ... snipped ... ]
>>
>> Thanks for pointing me in the right direction.  This is what I ended
>> up getting to work:
>>
>>            jQuery("span.event", ".calendar-table").each(function(){
>>                var html = this.innerHTML.replace(/(<br\s*\/*>)\s*\*/
>> g, \'$1\');
>>                jQuery(this).html(html) ;
>>            }) ;
>>
>> I changed the regular expression slightly to eliminate the .* portion
>> and changed .html() to .innerHTML.  I don't know enough jQuery to know
>> why I had to do that but had seen it elsewhere so tried it and it
>> worked.
>>
>> Thanks,
>>
>> Mike
>>
>
> .html() retrieves the innerHTML.
>
> Really no functional difference, but for the sake of consistency, since
> you're leveraging jQuery, I'd prefer to see consistent jQuery code (unless
> there's a compelling reason not to).
>
> And yeah... just a preference.  Not saying wrong or right.  But I am saying
> you shouldn't have "-had- to do that" :)
>
> Anyway, glad you got it working.  That's the important bit :)


... and after looking at your code (which always helps), I see you're
referencing "this" (as opposed to jQuery's $(this)), which is why html()
wouldn't have worked.

In that case, sure.  It's been said that "this" is more efficient than
creating a jQuery reference to it via $(this).

So to clarify... this.innerHTML is the functional equivalent of
$(this).html(), but without the "cost" of creating a new jQuery object for
each iteration of your each().

-- 
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.

Reply via email to