Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

h1 {
color: red;
text-align: center;

}
body {
background-color: aquamarine;
}
#window {
height: 400px;
width: 400px;
}
11 changes: 9 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello Front-End</title>
<link href="./index.css" rel="stylesheet" />
<script src="./js.js"></script>
</head>
<body>
<h1>Hello Front-End</h1>
<div>
<h1>Welcome To Reddit</h1>
<div class = "Search">
<div class = 'container' id="window"></div>
<button type="button" id="start">Go</button>
<button type="button" id="stop">Stop</button>
</div>
</body>
</html>
35 changes: 35 additions & 0 deletions js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
let counter = 4
const theImg = document.createElement('img')


document.addEventListener('DOMContentLoaded', () => {

fetch('https://www.reddit.com/search.json?q=pets+nsfw:no')
.then(res => res.json())
.then(data => {
console.log(data)
function img() {
theImg.src = data.children[count].data.thumbnail
theImg.style.width = '400px'
theImg.style.height= '400px'
const window = document.getElementById('window')
window.appendChild(theImg)


}
document.querySelector('#start').addEventListener('click', () => {
let interval = setInterval(() =>{
img()
counter+=1
},1500)
document.querySelector('#stop').addEventListener('click', () => {
theImg.src=""
counter = 4
clearInterval(interval)
})
})
})
.catch(error => {
console.log('Error',error)
})
} )