0
안녕하세요 저는 개발 도상국에서 새로운 사람들입니다. FreeCodeCamp를 팔로우하고 있으며 임의 견적 기계를 사용 중입니다. 트윗 단추를 추가하는 데 문제가 있습니다. 단추를 사용하지 않으면 견적을 트위트 할 수 있지만 추가 단추 솔루션을 사용할 때는 문제가 있습니다. 그것은 제목을 트윗합니다. 이걸로 나를 도울 수 있니? 이 도움이내 텍스트에 트윗 버튼 추가
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
사이트를 확인한 결과이 문제에 대해 아직 분실 했습니까? 다른 제안이 있습니까? 고맙습니다 –