From da9f07c190d0830dbb2e58cffb16937a298b63d8 Mon Sep 17 00:00:00 2001 From: kovacsrud <42613777+kovacsrud@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:51:15 +0200 Subject: [PATCH] =?UTF-8?q?N=C3=A9vsor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tanuloi_nevsor/ajax.js | 29 +++++++++++++++++++++++++++++ tanuloi_nevsor/index.html | 7 ++++--- tanuloi_nevsor/nevsor.js | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tanuloi_nevsor/ajax.js diff --git a/tanuloi_nevsor/ajax.js b/tanuloi_nevsor/ajax.js new file mode 100644 index 0000000..1227b7f --- /dev/null +++ b/tanuloi_nevsor/ajax.js @@ -0,0 +1,29 @@ +let request= new XMLHttpRequest(); + +let valasz=""; + +let root=document.getElementById('root'); + +request.open('GET','https://jsonplaceholder.typicode.com/posts',true); + +request.onload=function(){ + valasz=JSON.parse(this.response); + valasz.forEach(elem=>{ + let p=document.createElement('p'); + p.textContent=elem.title; + root.appendChild(p); + }); +} + +//request.send(); + +fetch('https://jsonplaceholder.typicode.com/posts') +.then(res=>res.json()) +.then(valasz=>{ + valasz.forEach(elem=>{ + let p=document.createElement('p'); + p.textContent=elem.title; + root.appendChild(p); + }) +}).catch(err=>alert(err)); + diff --git a/tanuloi_nevsor/index.html b/tanuloi_nevsor/index.html index d95ba88..8abadbf 100644 --- a/tanuloi_nevsor/index.html +++ b/tanuloi_nevsor/index.html @@ -4,11 +4,12 @@ Tanulói névsor - + + -

Tanulói névsor

-
+

Tanulói névsor

+
diff --git a/tanuloi_nevsor/nevsor.js b/tanuloi_nevsor/nevsor.js index 0656709..47440d2 100644 --- a/tanuloi_nevsor/nevsor.js +++ b/tanuloi_nevsor/nevsor.js @@ -42,6 +42,7 @@ for (let i = 0; i < darab; i++) { for (let i = 0; i < tanulok.length; i++) { let tanuloKontener=document.createElement('div'); + tanuloKontener.setAttribute('class','m-5 text-sky-800 bg-sky-200 w-64 p-2 border-2 shadow-xl rounded-xl outline-green-300') let tanulo_veznev=document.createElement('p'); tanulo_veznev.textContent=tanulok[i].vezeteknev;