[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-18 Thread Vincent Robert
What you want in full jQuery is: $("#foo").empty().append(''); which is the exact equivalent of $("#foo").html(''); // html() does call this.empty().append() It is very different from the browser innerHtml since your HTML will first be parsed by jQuery into a DOM tree while innerHtml just inse

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-17 Thread ken
You're right, somehow I missed it. Thanks everyone! On Wed, Dec 17, 2008 at 9:22 PM, Ricardo Tomasi wrote: > > What's wrong with the solution suggested by Kean above? It's prettier > than this and works fine. > > $('#foo').html('').find('img').attr > ("src","asdf.gif"); > > - ricardo > > On Dec 1

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-17 Thread Ricardo Tomasi
What's wrong with the solution suggested by Kean above? It's prettier than this and works fine. $('#foo').html('').find('img').attr ("src","asdf.gif"); - ricardo On Dec 17, 6:03 pm, ken wrote: > That's basically the form I've developed thus far: > >             var img = jQuery( '' ).attr( 'sr

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-17 Thread ken
That's basically the form I've developed thus far: var img = jQuery( '' ).attr( 'src', 'image.gif' ); jQuery( '#foo' ).html( img ).prepend( '' ).append( '' ); It just seems very inelegant contrasted with the 'normal' jQuery usage. On Wed, Dec 17, 2008 at 11:41 AM, Hector

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-17 Thread ken
The problem with that approach is, why even use jQuery for that? Might as well use .innerHTML = ... I was hoping to develop a pattern that could be reused, so that the SRC, or wrapping elements (BR's in this example) can be programmatically set or modified. This approach does not facilitate that.

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-17 Thread Hector Virgen
Or you could do this: var img = << your image element wrapped in s >> $('#foo').html(img); -Hector On Wed, Dec 17, 2008 at 9:36 AM, brian wrote: > > On Wed, Dec 17, 2008 at 11:13 AM, ken wrote: > > I need to replace the contents of #foo. > > > > I would love to use CSS, and if I were startin

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-17 Thread brian
On Wed, Dec 17, 2008 at 11:13 AM, ken 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 replac

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-17 Thread ken
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 beca

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-16 Thread Kean
Ken, I wanted to play by your rules BUT agreed with Brian on using CSS instead of On Dec 16, 5:18 pm, brian wrote: > On Tue, Dec 16, 2008 at 5:50 PM, ken wrote: > > I am trying to do the following: > > > 1) create an IMG > > 2) assign an SRC to the IMG > > 3) wrap the IMG in 's > > 4) insert t

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-16 Thread brian
On Tue, Dec 16, 2008 at 5:50 PM, ken wrote: > I am trying to do the following: > > 1) create an IMG > 2) assign an SRC to the IMG > 3) wrap the IMG in '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

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-16 Thread Kean
var foo = $("#foo"); foo.html('').find('img').attr("src","asdf.gif"); Tested and working. find( 'img' ) works for me. On Dec 16, 3:12 pm, ken wrote: > Scratch my "working" example -- the .find( 'img' ) evidently can't find the > image > > On Tue, Dec 16, 2008 at 4:50 PM, ken wrote: > > I

[jQuery] Re: What am I doing wrong here -- htmlTo?

2008-12-16 Thread ken
Scratch my "working" example -- the .find( 'img' ) evidently can't find the image On Tue, Dec 16, 2008 at 4:50 PM, ken wrote: > I am trying to do the following: > > 1) create an IMG > 2) assign an SRC to the IMG > 3) wrap the IMG in 's > 4) insert the resultant HTML into #foo > > I have been