大家早上好,我知道以前有人问过这个问题,但是作为我正在努力学习的 Javascript 新手,我无法理解如何让我的 Twitter 按钮分享随机引用。如果可能的话,请一位开发人员向我解释如何实际输入它。我对 HTML、CSS 和 Bootstrap 有很好的理解,但希望有人向我解释这一点。
提前谢谢了。
var quotes = [
"\'It is never too late to be what you might have been.\' - George Eliot",
"\'What lies behind us and what lies before us are tiny matters compared to what lies within us.\' - Henry Stanley Haskins",
"\'Great thoughts speak only to the thoughtful mind, but great actions speak to all mankind.\' - Emily P. Bissell",
"\'I haven’t failed. I’ve just found 10,000 ways that don’t work.\' - Thomas Edison",
"\'In between goals is a thing called life, that has to be lived and enjoyed.\' - Sid Caesar"
]
function newQuote() {
var randomNumber = Math.floor(Math.random() * (quotes.length));
document.getElementById('quoteDisplay').innerHTML = quotes[randomNumber];
}
<html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<h1>Simple Quote Generator</h1>
<div id="quoteDisplay">
</div>
<div class="quoteButton">
<button onclick="newQuote()">New Quote</button>
</div>
<a href="http://twitter.com/intent/tweet/?text" title="Share on Twitter" target="blank" class="btn btn-twitter-"><i class="fa fa-twitter"></i> Twitter</a>
<script src="javascript.js"></script>
</body>
</html>