function showTweet(username) {
$("<ul/>", {
"class": "my-user-list",
html: usertweets[username].join("<li/>")
}).appendTo($("#tweets"));
}
所以我看到选择器是针对无序列表,但逗号后面是什么,为什么它在花括号?如何阅读此功能?
我了解.append
部分。我不明白"class": "my-user-list"
和html: usertweets[username].join("<li/>")
做什么。请注意,usertweets
是一个数组。
任何有识之士将不胜感激!
文档中的所有:jQuery的创建元素W /属性](http://api.jquery.com/jquery/#jQuery-html-attributes) – epascarello
这是jQuery的... HTTP:// API .jquery.com/jQuery /#jQuery1 –
它检查'usertweets'对象的'username'键并将结果值包裹在''li'标签(放在'ul'中)。 – Andy