i have a function and event listener and inside them there are other functions and event listeners and so on. it works fine but for example if i want to change only the last element the code doesn't work (it doesn't throw any error or anything just straight up does nothing)
bear in mind that i want to get the last element of a <ul> that's being created in DOM by javascript
for example
function fonter () {
text.style.fontSize = "20px";
text.style.fontFamily="cursive";
}
font.addEventListener("click" , fonter);
this works perfectly fine but the problem is it changes the font of every element but for example if i change it to
text.lastChild.style.fontSize = "20px";
it does nothing. have it in mind that if i console log text.lastChild it shows the last child.
so 2 questions here . why doesn't this work even thou when i console log it , it shows up , and 2nd what's the best way to change like style or innertext or ... of last child in DOM? thanks
thanks