0
I want to delete a div with js using removeChild method but I must run the function twice why?
When I want to delete a child of a div object with js ,I must run my function twice.It seems like it had two text object in it whereas I put just one.Who knows about this issue?Why does it happen?
6 odpowiedzi
+ 3
Because empty space in html code is also a child node called TextNode.
The easy way is to leave no space between parent element and child element in the HTML code.
The other way is to use children() instead of childNode()
+ 3
What did Gordon mean was children, the ParentNode property.
+ 3
Yes yes, should be children, no () sorry ~
Reference is Calvin's answer to my Q&A :
https://www.sololearn.com/Discuss/1618304/?ref=app
+ 2
Share your code please.
+ 2
children() is only for jQuery it seems.
Gordon
+ 1
I tested the empty spaces and that is exactly correct.thank you Gordon