I do not think this means what you think. Change $(this) to an explicit link to the desired DOM element.
Alternatively, you can define this by calling:
tweetCount.call($("#element"), url)
Edit
Try the following:
$("span.tweetcount").each(function(){ url = $(this).attr('title'); tweetCount.call(this, url); });
Or, to save space:
$("span.tweetcount").each(function(){ tweetCount.call(this, $(this).attr('title')); });
Edit 2:
Try replacing tweetCount as follows:
function tweetCount(url) { var that = this; $.getJSON("http://urls.api.twitter.com/1/urls/count.json?url="+url+"&callback=?", function(data) { count = data.count; $(that).append(count); })
source share