嗨,我正在尝试自动从文本链接内容以分享...</p>
每个页面上有 20 个帖子需要链接,即为什么我做了 #tweet01
这是我的存根,但我想我错过了一些东西,非常感谢任何帮助,在此先感谢!
<p id="tweet01">When I was 10 I started washing cars. I then offered to clear paths for those without cars. I soon made money from most houses on my street.</p>
<div class="stream-item-footer">
<ul class="tweet-actions">
<script type="text/javascript">
var tweet = $("#tweet01").text()
var shortTweet = $("#tweet01").text() // get the text within the div
.trim() // remove leading and trailing spaces
.substring(0, 100) // get first 100 characters
.split(" ") // separate characters into an array of words
.slice(0, -1) // remove the last full or partial word
.join(" ") + "..."; // combine into a single string and append "..."
$(document).ready(function() {
$().html('<li><span class="st_twitter" st_url="http://www.domain.com" st_title="'+ ++shortTweet +'"></span></li>');
$().html('<li><span class="st_linkedin" st_url="http://www.domain.com" st_title="'+ ++tweet +'" st_summary="'+ ++tweet +'"></span></li>');
$().html('<li><span class="st_facebook" st_url="http://www.domain.com" st_title="'+ ++tweet +'" st_summary="'+ ++tweet +'"></span></li>');
$().html('<li><span class="st_googleplus" st_url="http://www.domain.com" st_title="'+ ++tweet +'" st_summary="'+ ++tweet +'"></span></li>');
});
</script>
</ul>
</div>