html5,添加推文页面部分的功能

html5, Adding ability to Tweet a section of a page

本文关键字:功能 文页面 添加 html5      更新时间:2023-09-26

我一直在看一个名为TwitThis的插件,但它用于在推特上发布您当前所在页面的地址/详细信息。

我想要实现的相当于这个:

(显然这只是概念性的,在有人说"你不能像你那样编码!"之前。

<ul>
  <li>Short section of text <tweet button> </li>
  <repeat ad nauseum>
</ul>

按下推文按钮将发布该 HTML 标签的内容

我知道这有点奇怪。

不需要JS库。使用 Twitter Intents。

.HTML:

<ul>
    <li><span>some text</span><button>Tweet</button></li>
    <li><span>some other text</span><button>Tweet</button></li>
</ul>​

JavaScript:

$('button').click(function() {
    window.open("https://twitter.com/intent/tweet?text="+$(this).parent().find('span').text());
});​

小提琴