<div class ="container-fluid text-center">
<h1> Random Quotes Machine</h1>
<p>Some inspirational quotes</p>
<img src=" https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQmwu_yAkcqXDjhxTM_cJzoua4fCmpz8qljtjYOjta6_dZWpWF6"/>
<br/>
<button type="button" class = "btn btn-default btn-primary" type = "Submit" id="newQuote"> New Quote</button>
<a href="#" class="btn btn-default btn-primary" id="tweet">Tweet out</a>
<div class ="quotes">
<span class ="quote">Hi</span>
<span class ="author">-There</span>
</div>
</div>
<div class="footer"> by <a href="https://codepen.io/SPIROSTSI/">Spiros</a>
</div>
$(document).ready(function(){
function getQuote(){
var quotes = ["Hi","Yo","Hiya","kkk"];
var authors = [ "1","2","3","4"];
//
var randomNum = Math.floor((Math.random()*quotes.length));
var randomQuote = quotes[randomNum];
var randomAuthor = author[randomNum];
$(".quote").text(randomQuote);
$(".author").text(randomAuthor);
}
$(".newQuote").on("click",function(){
getQuote();
});
$("#tweet").on("click",function(){
window.open("https://twitter.com/intent/tweet" );
});
});
You have some typos.
".newQuote"
should be "#newQuote"
.
author[randomNum]
should be authors[randomNum]
.
1 Like
Thanx!Iwas killing me forr days!!! I am really grateful!