Problem with twitter api
I want build a twitter ticker in a website. I have this code:
$(document).ready(function(){
$('#twitter-ticker').fadeIn('slow');
for(var i=0;i<tweetUsers.length;i++)
{
if(i!=0) buildString+='+OR+';
buildString+='from:'+tweetUsers[i];
}
var fileref = document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", "http://search.开发者_StackOverflowtwitter.com/search.json?q="+buildString+"&callback=TweetTick&rpp=50");
document.getElementsByTagName("head")[0].appendChild(fileref);
});
That is the first part of the javascript. In that script, javascript show the twitter ticker. But what is now my problem. I want a click event to this javascript.
On the website i have a twitter button. When i click on this twitter button. The twitter ticket must be show. But how can i make a click event to this javascript code? Thanks!
Using jQuery's .click() function you can attach a function to run whenever the selected element is clicked by the user.
You will also probably want to use $.getJSON() instead of manually attaching the <script>
tag.
精彩评论