js question

https://codepen.io/etrbbr/pen/LEPoMQZ Hey guys. When I add a new <li> element, an <hr> line should appear after each one. But the problem is that when I add it via JS, it works incorrectly. How it should look – in CodePen before adding new elements.
df
CodePen
Untitled
...
No description
7 Replies
Helgi
HelgiOP3w ago
And another problem: when I write a lot of text, like rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, it doesn't wrap. But if I add even a single space, everything works fine. What's the problem?
Mannix
Mannix3w ago
to fix the latter you can use word-break or overflow-wrap there is nothing in your js that adds the hr element
Helgi
HelgiOP3w ago
yes i think because i didnt add hr in codepen. i was adding my hr after <li> here that was the problem but can you check codepen again, i am doing smth wrong when aiam adding hr https://codepen.io/etrbbr/pen/LEPoMQZ
df
CodePen
Untitled
...
No description
Mannix
Mannix3w ago
i would move the creation of the hr element to the updateToDoList() and use after not append
let hr = document.createElement("hr");
hr.classList.add("line");
todoItem.after(hr);
let hr = document.createElement("hr");
hr.classList.add("line");
todoItem.after(hr);
Chris Bolson
Chris Bolson2w ago
I don't believe that <hr> is not a valid child element of a ul. If you need lines after each "todo" item it would be simplest to add a bottom border via CSS.
Mannix
Mannix2w ago
i didn't think of that and yeah border seems far easier way
Helgi
HelgiOP2w ago
hell.. i didnt think about that also thanks guys 😄

Did you find this page helpful?