我试图动态地向DOM添加元素来填充搜索结果列表。代码看起来像JQuery-在DOM中注入元素时保留字符串
for(var i=0; i<length; i++){
console.log(temp[i].CATEGORY);
console.log(temp[i].SUBCATEGORY);
table = table + '<tr class="search-tr"><td class="search-td"><a href="javascript:void(0)" onClick=window.parent.iframeLink("content-iframe","search-ui.cfm","'+temp[i].CATEGORY+'","d") target="content-window"><span class="subcat">'+temp[i].SUBCATEGORY+'</span><span class="cat"> in '+temp[i].CATEGORY+'</span></a></td></tr>';
}
当我检查通过所述浏览器,其被注入的字符串“临时[I] .CATEGORY”被认为是“服务器设置”的元素。相反,它被注入为“服务器”设置,这是造成一切打破。
我已经做了很多搜索的,但我无法找到任何引用到这个问题。
temp.category和temp.subcategory中的内容 –
您有一个'onClick'属性值不在引号内。 尝试'onClick = \'window.parent.iframeLink(“content-iframe”,“search-ui.cfm”,“'+ temp [i] .CATEGORY +'”,“d”)\'' – Titus
生成'temp [i] .CATEGORY'值? – Alexander