-
-
Notifications
You must be signed in to change notification settings - Fork 281
Sheffield | 26-ITP-Jan | Martha Ogunbiyi | Sprint 3| Sprint3 /Quote generator #1163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
1a5069a
ccc7e21
1e10e5a
4c08293
a854ec3
2bd68b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -489,5 +489,22 @@ const quotes = [ | |
| author: "Zig Ziglar", | ||
| }, | ||
| ]; | ||
|
|
||
| const title = document.querySelector("title") | ||
| title.textContent = "Quote generator app"; | ||
| // call pickFromArray with the quotes array to check you get a random quote | ||
| const quoteEl = document.querySelector("#quote"); | ||
| const authorEl = document.querySelector("#author"); | ||
| const button = document.querySelector("#new-quote"); | ||
|
|
||
| function displayQuote() { | ||
| const randomQuote = pickFromArray(quotes); | ||
|
|
||
| quoteEl.textContent = randomQuote.quote; | ||
| authorEl.textContent = randomQuote.author; | ||
| } | ||
|
|
||
| // Show initial quote on page load | ||
| displayQuote(); | ||
|
|
||
| // Change quote when button is clicked | ||
| button.addEventListener("click", displayQuote); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Placing all the "run on load" code in one place is a good practice. For examples, function setup() {
// code to be executed on page load
}
window.addEventListener('load', setup);or window.addEventListener('load', function() {
// code to be executed on page load
});
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the feed, onl page load function added |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,24 @@ | ||
| /** Write your CSS in here **/ | ||
| *{ | ||
| box-sizing: border-box; | ||
| } | ||
| body{ | ||
| background-color: orange; | ||
| } | ||
| .quote{ | ||
| background-color: white; | ||
| text-align: center; | ||
| padding: 50px; | ||
| margin: 50px; | ||
| color: orange; | ||
| font-size: larger; | ||
|
|
||
| } | ||
| button{ | ||
| position: absolute; | ||
| right: 120px; | ||
| background-color: orange; | ||
| color: white; | ||
| border: orange; | ||
| padding: 8px; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.