[stackoverflow] tweeter
3935920/jquery-selector-issue
by danmana
HTML
<div id="results"></div>
JavaScript
// twitter api's base url
var url = "http://search.twitter.com/search.json?callback=?&result_type=recent&q=";
// we'll store the search term here
var query = "blah";
// get the json file
$.getJSON(url + query, function(json) {
// this is where we can loop through the results in the json object
$.each(json.results, function(i, tweet) {
// this is where we do what we want with each tweet
$("#results").append('<div class="tweetBox"><span class="unseen">' + tweet.created_at + '</span><div class="tweetImg"><img src="' + tweet.profile_image_url + '" width="48" height="48" /><a class="overbox" href="http://twitter.com/' + tweet.from_user + '/status/' + tweet.id + '"></a></div>' + tweet.text + ' ...said ' + ((new Date().getTime() / 1000 / 60) - (new Date(tweet.created_at)) / 1000 / 60).toFixed(0) + ' minutes ago</div>');
});
alert('found '+$(".unseen").length+' objects');
});
$("#results").height(function() {
return $(window).height() - 204;
});