1
我試圖做一個Twitter的飼料爲我的網站,但是,我想顯示3最新的鳴叫,但在不同的div。Twitter的飼料與JQuery的 - 發佈3最近鳴叫到不同的div
我在這裏有這段代碼...我已經設置了3個變量,其中每個tweet將被存儲在各個類中。
我的主要問題是如何在循環中存儲每條推文(i)的數據。但這不起作用...有人可以告訴我哪裏會出錯嗎?歡呼聲
$(document).ready(function() {
// Call the Twitter API to retrieve the last 3 tweets in JSON format for the pcpro Twitter account
$.getJSON("http://twitter.com/statuses/user_timeline.json?screen_name=allaboutjames&count=3&callback=?", function(tweetdata) {
var t1 = $("#work-thumbs .tweet-1");
var t2 = $("#work-thumbs .tweet-2");
var t3 = $("#work-thumbs .tweet-3");
// For each item returned in tweetdata
$.each(tweetdata, function(i,tweet) {
// Append the info in li tags to the ul, converting any links to HTML <a href=.. code and convert the tweeted date
// to a more readable Twitter format
t(i).append("<li>“" + urlToLink(tweet.text) + "”– " + relTime(tweet.created_at) + "</li>");
});
});
});
這裏是小提琴http://jsfiddle.net/kbKW9/ – Rafay
感謝您添加小提琴;這是一個好主意。但是,它不包含我的代碼,但有一個稍微不同的選擇。 – middus