You're right, somehow I missed it. Thanks everyone! On Wed, Dec 17, 2008 at 9:22 PM, Ricardo Tomasi <ricardob...@gmail.com>wrote:
> > What's wrong with the solution suggested by Kean above? It's prettier > than this and works fine. > > $('#foo').html('<br/><img /><br/>').find('img').attr > ("src","asdf.gif"); > > - ricardo > > On Dec 17, 6:03 pm, ken <jqu...@kenman.net> wrote: > > That's basically the form I've developed thus far: > > > > var img = jQuery( '<img/>' ).attr( 'src', 'image.gif' ); > > jQuery( '#foo' ).html( img ).prepend( '<br/>' ).append( > '<br/>' > > ); > > > > It just seems very inelegant contrasted with the 'normal' jQuery usage. > > > > On Wed, Dec 17, 2008 at 11:41 AM, Hector Virgen <djvir...@gmail.com> > wrote: > > > Or you could do this: > > > > > var img = << your image element wrapped in <br />s >> > > > $('#foo').html(img); > > > > > -Hector > > > > > On Wed, Dec 17, 2008 at 9:36 AM, brian <bally.z...@gmail.com> wrote: > > > > >> On Wed, Dec 17, 2008 at 11:13 AM, ken <jqu...@kenman.net> wrote: > > >> > 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). > > > > >> ok, then, how about just using a string instead of setting the > attributes > > >> later? > > > > >> $('#foo').html('<br /><img src="image.gif" /><br />'); >