I need to replace the contents of #foo.

I would love to use CSS, and if I were starting anew that would be the case,
but unfortunately I am working on an existing application converting the
plain-jane JS to jQuery. I'm simply trying to replace existing functionality
WITHOUT affecting the HTML because the HTML is very fragile (the existing JS
utilizes DOM walking exclusively, so removing/replacing nodes causes a
cascade of fail).



On Tue, Dec 16, 2008 at 7:21 PM, Kean <shenan...@gmail.com> wrote:

>
> Ken, I wanted to play by your rules BUT agreed with Brian on using CSS
> instead of <br />
>
> On Dec 16, 5:18 pm, brian <bally.z...@gmail.com> wrote:
> > 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