Skip to content

Instantly share code, notes, and snippets.

@syafiqfaiz
Created January 28, 2025 15:08
Show Gist options
  • Save syafiqfaiz/6373fc7a55594330716fc2ad75d36620 to your computer and use it in GitHub Desktop.
Save syafiqfaiz/6373fc7a55594330716fc2ad75d36620 to your computer and use it in GitHub Desktop.
placeholder json
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript DOM Manipulation Demo</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.highlight {
background-color: yellow;
}
ul {
padding: 0;
}
li {
list-style: none;
margin: 5px 0;
padding: 5px;
border: 1px solid #ccc;
border-radius: 4px;
}
.completed {
text-decoration: line-through;
color: gray;
}
</style>
</head>
<body>
<h1>JavaScript DOM Manipulation</h1>
<section id="list-demo">
<h2>todo list</h2>
<ul id='todoList'></ul>
</section>
<script>
const listContainer = document.getElementById('todoList')
fetch('https://jsonplaceholder.typicode.com/todos/')
.then((response) => response.json())
.then((body) => {
for (let i = 0; i < body.length; i++) {
const item = document.createElement('li')
item.innerText = body[i].title
// console.log(item)
listContainer.appendChild(item)
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment