How to send tweet to twitter with jquery inside my site

别说谁变了你拦得住时间么 提交于 2019-12-04 07:05:46

What's wrong with:

<a href="https://twitter.com/share" class="twitter-share-button" data-text="Something other than page title" data-count="vertical">Tweet it</a></div>

You can even set it dynamically via:

$('.twitter-share-button').attr('data-text', 'Some text to tweet');

UPDATE: If you're just trying to use your own Twitter button, you can simply use web intents, Twitter's fancy way of saying "regular old URLs". See: https://dev.twitter.com/docs/intents

https://twitter.com/intent/tweet?url=[your URL]&text=[some text to tweet]

Since it's part of a URL, make sure you urlencode all the parameters.

here is some sample code i have found... I still have the big ugly twitter button !

<script>
$(document).ready(function(){
    $('a[data-text]').each(function(){
      $(this).attr('data-text', "This works!");
    });
    $.getScript('http://platform.twitter.com/widgets.js');
});
</script>

<a href="http://twitter.com/share"
    class="twitter-share-button"
    data-text="This is what we want to change dynamically"
    data-count="none" data-via="chris_camps">Tweet</a>
<!-- moved to the js above <script type="text/javascript"
    src="http://platform.twitter.com/widgets.js"></script> -->
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!