On Tue, Dec 16, 2008 at 5:50 PM, ken <jqu...@kenman.net> wrote:
> I am trying to do the following:
>
> 1) create an IMG
> 2) assign an SRC to the IMG
> 3) wrap the IMG in <br/>'s
> 4) insert the resultant HTML into #foo
>
> I have been hammering at this for awhile now, and am having problems; I've
> tried using wrap and some of the other content-manipulation methods, but I
> still can't get the implementation down to something short and sweet
> (referencing jQuery only once). This is the best I've got so far:
>
>     var html = jQuery( '<br/><img/><br/>' )
>         .find( 'img' ).attr( 'src', 'image.gif' ).end();
>
>     jQuery( '#foo' ).html( html );
>

Do you want to replace the contens of #foo or just insert the img?

$('<img/>')
        .attr('src', 'loading.gif')
        .appendTo('#foo');

Forget the BRs and use CSS.

Reply via email to