Я пытаюсь добавить некоторые элементы в DOM, но консоль FireBug продолжает предупреждать меня об ошибке, говоря, что TypeError: el.appendChild is not a function; el.appendChild(para); TypeError: el.appendChild is not a function; el.appendChild(para); Итак, вот js:
Нашли некоторые общие проблемы, но не смогли найти способ решить мою проблему.
возвращает коллекцию элементов. Вам нужно выбрать элемент из коллекции, прежде чем вы сможете добавить к нему ребенка.
Если вы знаете ровно один, вы можете использовать:
Поскольку неясно, ожидаете ли вы добавлять узлы ко всем элементам данного класса, я буду явно предполагать, что это то, что вы ожидаете сделать.
Эта форма довольно многословна. Если вы используете jQuery, то гораздо проще написать:
this is my javascript
it is throwing error «AppendChild is not a function» . I tried to search for solution .. it was suggested that on the place of
this should be posted
it didnt change the error . Please suggest
- 5 Answers 5
- Not the answer you’re looking for? Browse other questions tagged javascript html .net or ask your own question.
- Linked
- Related
- Hot Network Questions
- Comments
- rohithpalagiri commented Oct 2, 2016
- This comment has been minimized.
- kimmobrunfeldt commented Oct 3, 2016
- This comment has been minimized.
- markphd commented Oct 4, 2016
- This comment has been minimized.
- kimmobrunfeldt commented Sep 9, 2017
5 Answers 5
Your div variable is a string, not a DOM element object:
Strings don’t have an appendChild method. Instead of creating a raw HTML string, create the div as a DOM element and append a text node, then append the input element:
«div» is not a DOM object,is just a string,and string has no string.appendChild.
Here are some references that may help you on appendChild method:
Try the following:
Not the answer you’re looking for? Browse other questions tagged javascript html .net or ask your own question.
Linked
Related
Hot Network Questions
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2019.11.15.35459
Comments
Copy link Quote reply
rohithpalagiri commented Oct 2, 2016
Anyone know what’s causing this?
This comment has been minimized.
Copy link Quote reply
kimmobrunfeldt commented Oct 3, 2016
Could you provide a reproducable example of code? It is almost impossible to say without seeing any context. Fork this JSFiddle: http://jsfiddle.net/kimmobrunfeldt/8xa87k31/392/
That sounds like bug in the library for not binding this correctly.
This comment has been minimized.
Copy link Quote reply
markphd commented Oct 4, 2016
@rohithpalagiri I recently encountered this error, when you initialize ProgressBar object, the first argument is the container and in the old version, this is how ProgressBar is initiated:
I played around with it and replaced container with the actual element you want to target as String
And that fixed the error.
This comment has been minimized.
Copy link Quote reply
kimmobrunfeldt commented Sep 9, 2017
Closing due to inactivity.
- © 2019 GitHub , Inc.
- Terms
- Privacy
- Security
- Status
- Help
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.