jquery
  • share
  • sharethis
  • 2013-03-20 87 views 0 likes 
    0

    我加載sharethis按鈕進入的fancybox按鈕點擊使用span標籤:變化ShareThis標題點擊

    <div style="display:none"> 
        <div class="social-share"> 
         <span class='st_facebook_vcount' displayText='Facebook'></span> 
         <span class='st_twitter_vcount' displayText='Tweet'></span> 
         <span class='st_pinterest_vcount' displayText='Pinterest'></span> 
        </div> 
    </div> 
    

    我的問題是:

    我怎樣才能改變st_title或設置標題爲根據我點擊的按鈕分享內容。例如,我的網頁已基本上一個分享按鈕,每個崗位,所以如果我想製作一個按鈕,像這樣的:

    <a class="share-btn" href="#" data-title="First Post">Share This</a> 
    

    ,然後嘗試做一些事情在這裏:

    $('a.share-btn').on('click', function(e){ 
         //Change shared title 
    
         //launch fancybox containing share <span>'s mentioned above 
    } 
    

    回答

    -1

    可以通過data()setter方法設置標題。

    $('a.share-btn').on('click', function(e){ 
         e.preventDefault(); 
         var titletext='some title'; 
         $(this).data('title',titletext); 
    } 
    
    相關問題