Skip to content

Instantly share code, notes, and snippets.

@hemangsk
Created January 4, 2016 17:47
Show Gist options
  • Save hemangsk/991d45b0a4a4da79a72d to your computer and use it in GitHub Desktop.
Save hemangsk/991d45b0a4a4da79a72d to your computer and use it in GitHub Desktop.
Random Quote Generator
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
<link href="style.css" type = "text/css" rel="stylesheet">
</head>
<body>
<h1><center>RANDOM QUOTE GENERATOR</center></h1>
<h3>A pen by Hemang Kumar</h3><br>
<p>
Welcome to Random Quote Genrator.
<br>
Click on the Generate Quote Button and get a awesome
quote generated.
</p>
<center><button id="but" type="button" value="button" name="button" >Get an awesome Quote</button></center>
<div id="showhere"></div>
</body>
</html>
var toprint="";
$(document).ready(function(){
$("#but").click(function(){
var myQuotes = [
{ "author":"Oscar Wilde",
"quotes":["A gentleman is one who never hurts anyone’s feelings unintentionally.",
"A little sincerity is a dangerous thing, and a great deal of it is absolutely fatal.",
"Ambition is the last refuge of the failure.",
"Bigamy is having one wife too many. Monogamy is the same.",
"Fashion is a form of ugliness so intolerable that we have to alter it every six months.",
"I am so clever that sometimes I don’t understand a single word of what I am saying.",]
},
{
"author": "Nora Ephron",
"quotes":["A gentleman is one who never hurts anyone’s feelings unintentionally.",
"A little sincerity is a dangerous thing, and a great deal of it is absolutely fatal.",
"If pregnancy were a book they would cut the last two chapters.",
"Beware of men who cry. It’s true that men who cry are sensitive to and in touch with feelings, but the only feelings they tend to be sensitive to and in touch with are their own.",
"The Wonderbra is not a step forward for women. Nothing that hurts that much is a step forward for women.",
"When your children are teenagers, it’s important to have a dog so that someone in the house is happy to see you.",]
}
]
var num = Math.floor((Math.random() *7) + 0);
var num2= Math.floor((Math.random()* 3)+0)
toprint= myQuotes[num2].quotes[num] + "<br><br> Author<br><strong> " + myQuotes[num2].author+ "</strong>";
console.log(toprint);
//your code here
$("#showhere").html(toprint);
});
});
body{
font-family:"Poiret One";
padding:100px
}
p{
font-size:20px;
text-align:center;
}
button{
font-family:"Source Sans Pro";
font-size:15px;
text-align:center;
position:relative;
}
h3{
font-family:"Source Sans Pro";
text-align:center;
font-size:15px;
}
#showhere{
font-family:"Source Sans Pro";
text-align:center;
padding-top:30px;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment