[object HTMLCollection]
the js: function addExample(id, divid) { //an array litral for adding our examples into it var added = []; var x = document.getElementById(id); var i = document.getElementsByTagName("input"); added.push(i); if (added.length > 0) { //creating a new paragraph var p = document.createElement("p"); var node = document.createTextNode(added); //adding the text to the paragraph p.appendChild(node); var div = document.getElementById(divid); //adding the paragraph to the div div.appendChild(p) var parent = document.getElementById(divid); var child = document.getElementById(id); parent.removeChild(child); } x.innerHTML = added; } the html : <div class="container" id="commonNouns"> <p id="ans"></p> <div id="addex"></div> <input type="text"/> <button type="button" class="btn btn-primary" onclick="addExample('ans', 'addex');">Add!</button><br /> </div> //---------------- when i write any thing in the input it is pupposed to be added in the div, but instead [object htmlCollection] appears