0
こんにちは、私は開発途上国の新しい人です。私はFreeCodeCampをフォローしています。私はランダムクォートマシンにいます。 Tweetボタンを追加する際に問題があります。ボタンを使用しないと引用符をつぶすことはできますが、追加ボタンのソリューションを使用すると問題が発生します。それはタイトルをつぶやく。これで私を助けてくれますか?私のテキストにツイートボタンを追加する
document.getElementById('tweetBtn').dataset.text = quotes[index] + ' - ' + quoteA[index];
・ホープ、このことができます: は、あなたのHTMLで
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RandomQuoteMachine</title>
<script src="jquery-3.1.0.js"></script>
<script type="text/javascript" src="script.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<div id= "target">
<h2>Quote of the Day</h2>
<div id="quoteRandom">
<p lang="en"></p>
</div>
<div id="authorRandom">
<p></p>
</div>
<div id="quoteButton">
<button>Click Me</button>
<a class="twitter-share-button" id="tweetPop" target="_blank" href="https://twitter.com/intent/tweet" data-size="large">Tweet</a>
</div>
</div>
</body>
</html>`
$(document).ready(function(){
var source = [
{author:"Thomas Edison", qoute:"I have not failed. I have successsfully discovered 10,000 things that will not work."},
{author:"George Bernard Shaw", qoute:"Science never solves a problem without creating ten more,"},
{author:"Vanna Bonta", qoute:"Imposible is not a Scientific Term"},
{author:"Albert Einstein", qoute:"The important thing is to never stop questioning"},
{author:"Leonardo daVinci", qoute:"Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it."},
{author:"Leornardo Davinci", qoute:"Learning never exhausts the mind."},
{author:"Adam Smith", qoute:"Science is the great antidote to the poison of enthusiasm and superstition."},
{author:"Bill Gates", qoute:"The first rule of any technology used in a business is that automation applied to an efficient operation will magnify the efficiency. The second is that automation applied to an inefficient operation will magnify the inefficiency. "},
{author:"Stephen Hawking", qoute:"Scientists have become the bearers of the torch of discovery in our quest for knowledge."},
];
$('#quoteButton').click(function(){
$('#target').css("background-color", "#F0D7F7");
});
$.getScript('http://platform.twitter.com/widgets.js');
$('body').on("click", "button", function() {
var quoteLength= Math.floor(Math.random() * source.length);
$('#quoteRandom')
.html("<p><q>" + (source[quoteLength].qoute) + "</q></p>")
.css('opacity', 1)
.fadeIn(30)
$('#authorRandom')
.html("<p>" + (source[quoteLength].author) + "</p>")
.css('opacity', 1)
.fadeIn(30)
$('#tweetPop')
.attr("href", "https://twitter.com/intent/tweet?text=" + ' " ' + (source[quoteLength].qoute) + ' " - ' + (source[quoteLength].author));
});
});
この文書を読む:https://dev.twitter.com/web/tweet-button – user3502626
私はそのサイトをチェックしましたが、私はまだこの問題で迷っています。別の提案がありますか?ありがとうございました –