36 lines
1.1 KiB
HTML
36 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Feladat2</title>
|
|
</head>
|
|
<body>
|
|
<div id="todos"></div>
|
|
<script>
|
|
let url = "https://jsonplaceholder.typicode.com/todos";
|
|
fetch(url)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
let elsoot = data.slice(0, 5);
|
|
|
|
elsoot.forEach(element => {
|
|
let divelement = document.createElement("div");
|
|
let cim = document.createElement("h2");
|
|
cim.innerHTML = element.title;
|
|
|
|
let asd = document.createElement("p");
|
|
asd.innerHTML = `Az elem azonosítója: ${element.id} <br>
|
|
Az elem befejezésének állapota: ${element.completed ? "befejezve" : "nem befejezett"}`;
|
|
|
|
divelement.appendChild(cim);
|
|
divelement.appendChild(asd);
|
|
|
|
document.getElementById("todos").appendChild(divelement);
|
|
});
|
|
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |