我有从提要加载数据的代码。您可以在此处查看 jsfiddle 。
<div class="agenda"></div>
<div class="agenda"></div>
<script>
label = ["Tutorials", "Widgets"];
for (m = 0; m < label.length; m++) {
function listEvents(json) {
var feed = json.feed;
for (var i = 0; i < 10; i++) {
var entry = json.feed.entry[i];
var posttitle = entry.title.$t;
//Style
if (i == 0) {
x = "<span style='color:red'>Style 1 + Label 1</span><p>" + posttitle + "</p>";
p = "<span style='color:red'>Style 2 + Label 2</span><h4>" + posttitle + "</h4><p>";
}
if (i == 1) {
y = "<p>" + posttitle + "</p>";
g = "<h4>" + posttitle + "</h4></p>";
}
}
style = [x + y, p + g];
for (m = 0; m < style.length; m++) {
document.getElementsByClassName("agenda")[m].innerHTML = style[m];
}
}
document.write("<script src=\"http://www.allbloggertricks.com/feeds/posts/default/-/" + label[m] + "?orderby=published&alt=json-in-script&callback=listEvents\"><\/script>");
}
</script>
我使用For
循环从2 Labels (Tutorials, Widgets)
.
对于每个标签,我希望它使用每种样式(normal and bold
如 jsfiddle 中的示例)。但我不知道为什么它只从Label
.
我需要你的帮助。感谢所有建议。