HTML元素未声明id

时间:2014-02-27 11:24:00

标签: jquery html dom

$("#main-container").html("<div class='span12 category-container'>"+
   "<span class='color-line' id='coloredline'></span>"+
   "<span class='span11 cate-name' id='category-span'>"+this.category+"</span>"+
   "<span class='span11 comment-like-flag'>"+"<span class='span12 flag'>"+this.desc+"<span>"+
       "<span class='span12 flag'>"+
           "<img src=<c:url value='resources/img/postNeedIcons/flag-icons.png'/> class='flag-icon'/>"+
           "<span class='valuedigit'></span>"+
           "<span class='supportxt'>"+this.needCount+" people supported this need</span>"+
       "</span>"+
   "</span>"+
"</div>");

上面id='coloredline'的代码span没有显示在萤火虫中。

1 个答案:

答案 0 :(得分:0)

您生成的html有一些错误

"<img src=<c:url value='resources/img/postNeedIcons/flag-icons.png'/> class='flag-icon'/>"

无效

尝试实现如下:

"<img src='http://farm6.staticflickr.com/5519/10965435794_1f0feaf89e_m.jpg' class='flag-icon'  />"

有关完整的工作示例,请参阅fiddle