On Sep 16, 2006, at 10:16 PM, Karl Swedberg wrote:

> works brilliantly! ( after changing the period to a semicolon  in the
> line, " firstP.innerHTML = text.slice(1). " )
>
> On Sep 16, 2006, at 8:48 PM, John Resig wrote:
>
>> Maybe something like this?
>>
>> function swap_letter() {
>>   var firstP = $('#main-content p:first-child')[0];
>>   var text = firstP.innerHTML;
>>
>>   if ( text ) {
>>     firstP.innerHTML = text.slice(1).
>>     $('<img />')
>>         .src('/images/alphabet/' + text[0].toLowerCase() + '.gif')
>>         .addClass('fancy-letter')
>>         .prependTo( firstP );
>>   }
>> }
>>
>> I wish it was just as easy to deal with text as it was the DOM.
>> (Hmm... a new plugin?)
>
>

Well, I guess I spoke too soon. It does work brilliantly in Firefox  
and Safari, but I get an error in IE6 related to $('<img />')

        Error: '0' is null or not an object

So it chops off the first letter, but doesn't add the image.

Any ideas?

Karl
_______________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to