51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
|
document.getElementById("hozzaadGomb").addEventListener("click", function () {
|
||
|
let feladatNev = document.getElementById("feladatNev").value;
|
||
|
let hatarido = document.getElementById("hatarido").value;
|
||
|
if(feladatNev != "" && hatarido != ""){
|
||
|
creatediv(feladatNev, hatarido);
|
||
|
} else {
|
||
|
alert("Nem kitöltött mezők!");
|
||
|
|
||
|
}
|
||
|
document.getElementById("feladatNev").value = null;
|
||
|
document.getElementById("hatarido").value = null;
|
||
|
});
|
||
|
|
||
|
|
||
|
let creatediv = (feladat, hatarido) =>{
|
||
|
let divelement = document.createElement("div");
|
||
|
divelement.className = "feladat";
|
||
|
divelement.innerHTML = `<b>Feladat:</b> ${feladat}<br><b>Határidő:</b> ${hatarido}`;
|
||
|
|
||
|
let modositgomb = document.createElement("button");
|
||
|
modositgomb.textContent = `Módosít`;
|
||
|
modositgomb.className = "modositasGomb";
|
||
|
|
||
|
let keszgomb = document.createElement("button");
|
||
|
keszgomb.textContent = `Kész`;
|
||
|
keszgomb.className = "keszGomb";
|
||
|
|
||
|
|
||
|
|
||
|
divelement.appendChild(modositgomb);
|
||
|
divelement.appendChild(keszgomb);
|
||
|
|
||
|
keszgomb.addEventListener("click", function () {
|
||
|
this.parentNode.remove();
|
||
|
});
|
||
|
|
||
|
modositgomb.addEventListener("click", function () {
|
||
|
let ujfeladat = prompt("Feladat új neve:");
|
||
|
let ujhatarido = prompt("Határidő új értéke:")
|
||
|
|
||
|
|
||
|
this.parentNode.innerHTML = `<b>Feladat:</b> ${ujfeladat}<br><b>Határidő:</b> ${ujhatarido}`;
|
||
|
divelement.appendChild(modositgomb);
|
||
|
divelement.appendChild(keszgomb);
|
||
|
});
|
||
|
|
||
|
document.getElementById("feladatok").appendChild(divelement);
|
||
|
}
|
||
|
|
||
|
|