+ 1
Please why is the word "happy" not appended to the list
7 Answers
+ 5
I don't know if you changed things or not, but happy isn't added to the list as line 8 generates a runtine error. 'getElementsByTagName' returns a list as indicated by the 's' of 'Elements'. Trying to use the list as a single element fails.
Change 'total.appendChild' to 'total[0].appendChild' to reference the one and only 'ul' tag and happy will be added to the list. However, you HTML will look like this:
<ul>
<li>rat</li>
<li>goat</li>
<li>woman</li>
<li><text>happy</text></li>
</ul>
+ 2
I added it Sir but it still isn't appending and returning the runtime error
+ 2
Sorry for the delay. Here you go:
https://code.sololearn.com/WH7eLK6MG9a4
+ 1
please could you please fork it and paste the link
+ 1
and please what do you mean by 's" of elements
+ 1
thanks alot sir
0
As @John wells said, replace total with total[0] and your statement will look like this:
total[0].appendChild(add);