有很多关于添加 <li>
元素的正确语法的结果,但我正在尝试找到一种解决方案,其中+this['name']+
的值包含在<li>
中。 Firebug 显示 'SyntaxError: unterminated string literal'
,jslint 显示'Unclosed string'
。我已尝试许多不同的逗号放置方式,但无法使其工作。
$.each(data.result, function() {
$("ul").append("<li>Name: "+this['name']+"</li>
<li>Age: "+this['age']+"</li>
<li>Company: "+this['company']+"</li>
<br />");
});
谢谢你。
\
,但并不是所有地方都兼容(或类似的情况)。还是采用安全的方式吧。 - Ian