简体   繁体   中英

how to add an onclick event to a Twitter button?

I would like to do an Ajax request for my Twitter button(https://dev.twitter.com/docs/tweet-button) before going to Twitter. So before I redirect to the Twitterlogin popup I would like to do something like this(js):

  window.addEvent('domready', function () {
           $('twitterbut').setProperties({
                 onclick: "//do ajax call;return (true);"
             });
         });

I tried this but it does not work:( How can I add an onclick event similar to above working?

Just read Element.Event documentation and use the correct method, ie addEvent :

window.addEvent('domready', function () {
     $('twitterbut').addEvent('click', function() {
           //do ajax call
     });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM