Bacon Ipsum on tasuta API, mis genereerib juhuslikult kalatäideteksti (kohatäiteteksti), mis põhineb lihasõnadel, nagu “peekon”, “sink” jne. Seda kasutavad veebiarendajad ja disainerid veebisaitide ja rakenduste loomisel tekstiplokkide ajutiseks täitmiseks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | <! DOCTYPE html> < html lang = "en" > < head > < meta charset = "UTF-8" /> < meta name = "viewport" content = "width=device-width, initial-scale=1.0" /> < meta http-equiv = "X-UA-Compatible" content = "IE=edge" /> < title >Styled Template</ title > < style > body { font-family: Arial, sans-serif; background-color: #f4f4f4; color: #333; text-align: center; margin-top: 50px; } button { background-color: red; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; } button:hover { background-color: green; } p { margin-top: 20px; font-size: 18px; } </ style > </ head > < body > < button type = "button" onclick = "loadDoc()" >Request bacon</ button > < p id = "demo" ></ p > < script > function loadDoc() { const xhttp = new XMLHttpRequest(); xhttp.onload = function () { const response = JSON.parse(this.responseText); const listContainer = document.getElementById("demo"); const ul = document.createElement("ul"); response.forEach(function (item) { const li = document.createElement("li"); li.textContent = item; ul.appendChild(li); }); listContainer.innerHTML = ""; listContainer.appendChild(ul); }; xhttp.open("GET", "https://baconipsum.com/api/?type=all-meat"); xhttp.send(); } </ script > </ body > </ html > |
