tags:

views:

37

answers:

2

I'm building a page of thumbnails with jQuery like this:

ID=this.id;
$('#thumbs').empty().html('<span class="title">'+$('#'+ID).html())+'</span><br />';
var i = 1;
for (i=1;i<=count[ID];i++)
    {
    $('#thumbs').append('<img class="thumb" src="graphics/thumbs/'+ID+'/'+i+'.jpg" />');
    }

The idea being that the <span> would appear, followed by <br /> and then the thumbs, which are simply inline graphics with bottom and right margins, would fill up the rest of the page. And they do-- except, the line break doesn't happen.

I am using Dreamweaver, so I can watch the code live, and sure enough, the script isn't inserting the <br /> tag at all.

Does this have something to do with jQuery's HTML parsing? If so, how to get around it?

+3  A: 

Not a jQuery issue (at least, not in version 1.4.2)

http://www.jsfiddle.net/SbFgf/

Taking a second look at your code, I realized you got an early closing paranthesis:

$('#thumbs').empty().html('<span class="title">'+$('#'+ID).html()+'</span><br />');

That should do it.

jAndy
altho to be fair, if that code is an exact copy of OP's code, none of the HTML inserted by that call should be there, so *at least* the title span should be missing as well, and the code would probably not continue to execute beyond that error at all, so most likely, *all* inserted code should be missing.
David Hedlund
but +1 nonetheless, for this not being a jQuery issue...
David Hedlund
As I've said before, I'm so glad something is wrong with me and not jQuery.
Isaac Lubow
A: 

Its not the problem with jquery's html() function. I did a quick test here and it works. (also in 1.3.2) Maybe the $('#'+ID).html()) is messing it up

naikus