diff --git a/tothadam_JavascriptNotes/index.html b/tothadam_JavascriptNotes/index.html new file mode 100644 index 0000000..9e4fa95 --- /dev/null +++ b/tothadam_JavascriptNotes/index.html @@ -0,0 +1,26 @@ + + + + + + + Jegyzettömb + + + + +

Jegyzettömb

+
+
+

+
+

+

+ +

+
+
+ +
+ + \ No newline at end of file diff --git a/tothadam_JavascriptNotes/script.js b/tothadam_JavascriptNotes/script.js new file mode 100644 index 0000000..33618bd --- /dev/null +++ b/tothadam_JavascriptNotes/script.js @@ -0,0 +1,40 @@ +const button = document.getElementById("addbtn") +const notes = document.getElementById("notes") +const msg = document.getElementById("msg") +let idnum = 1 + + +button.addEventListener("click", ()=>{ + let inphead = document.getElementById("inphead") + let inptext = document.getElementById("inptext") + console.log(inphead.value); + if (inphead.value != "" && inptext.value != ""){ + let newnote = document.createElement("div") + newnote.innerHTML = `

${inphead.value}

` + newnote.innerHTML += `

${inptext.value}

` + newnote.classList.add("notescss") + newnote.setAttribute("id", `note-${idnum++}`) + newnote.setAttribute("title", "Kattintásra törölheted a jegyzetedet...") + newnote.style.background = document.getElementById("notecolor").value + notes.appendChild(newnote) + msg.innerHTML = "" + msg.innerHTML = "Üzenet hozzáadva!" + inphead.value = "" + inptext.value = "" + + newnote.onclick = function(){ + this.parentElement.removeChild(this) + + } + + notes.appendChild(newnote) + + msg.innerHTML = 'Üzenet hozzáadva!