推文按钮故障

时间:2016-04-30 19:05:39

标签: javascript jquery button twitter target

我对这一点感到沮丧,我想看看你们将这些结合在一起的方式。我需要推文按钮来分享生成的报价。我觉得我已经连接了所有东西......显然缺少一些东西,但不确定是什么。之前,我能够在新窗口中显示推文框,但引用文本并没有在那里结束。我删除了,现在我无法重新连接所有内容与...内的引用...

HTML:

    <div class="container-fluid">
    <body>
      <div class = "row-text-center">
        <h2>Random Quote Machine</h2>
        <p>These are some of my favorite quotes from my favorite books. Enjoy!</p>
      </div>
      <div class = "row-text-center">
        <div class = "col-xs-12 well message" id="quoteHere">
      </div>
      <div class = "row-text-center">
        <div class = "col-xs-12 col-sm-12 col-md-12 col-lg-12">
     <a class="twitter-share-button" href="https://twitter.com/intent/tweet/?text=" data-size="large"><button type="button" class="btn btn-info" id="tweet">Tweet Quote</button></a>
     <button id = "newQuote" class = "btn btn-primary">
            New Quote
          </button>
        </div>
      </div>
    </body>
    </div>


JavaScript:

    var quote = [
    "I could die for you. But I couldn't, and wouldn't, live for you." + "  — Ayn Rand, The Fountainhead",
   ];
//quotes continue (shortened for easy reading)


    function showQuote(num) {
        return quote[num];
    }
    $(document).ready(function() {
    $('#newQuote').click(function() {
    $('#quoteHere').html(showQuote(Math.floor(Math.random() * 16)));
    $('#tweet').on('click', tweetQuote);
    });
    });

    function tweetQuote() {
      var tweet = $('#quoteHere').text();
      $('#tweet').attr('href', 'https://twitter.com/intent/tweet?text=' + tweet);
    }

    $(document).ready(function() {
      getQuote();    
      $('#newQuote').on('click', showQuote);
      $('#tweet').on('click', tweetQuote);
    });

0 个答案:

没有答案