removechild

removeChild is not a function

守給你的承諾、 提交于 2021-01-28 19:15:57
问题 window.onload = initPage; var firstname = false; var lastname = false; function initPage() { addEventHandler(document.getElementById("firstname"), "blur", verifyFirst); addEventHandler(document.getElementById("lastname"), "blur", verifyLast); addEventHandler(document.getElementById("submit"), "click", showName); } function verifyFirst(e) { var me = getActivatedObject(e); if (me.value === "") { me.className = "error"; me.focus(); me.select(); return; } else { me.className = ""; firstname =

How can I clone and remove a html form with JavaScript(js)?

∥☆過路亽.° 提交于 2021-01-05 23:57:22
问题 I want to clone a form and then have the option to remove the form that I have just created. I know how to clone it, but not how to remove it. I have only be able to remove the original form, but not the clonned form. This is my code: function duplicate(id) { var elmnt = document.getElementById(id); var cln = elmnt.cloneNode(true); var num = 1; cln.id = id + num; document.body.appendChild(cln); } function remove(id) { var elem = document.getElementById(id); elem.parentNode.removeChild(elem);

How can I clone and remove a html form with JavaScript(js)?

折月煮酒 提交于 2021-01-05 23:55:59
问题 I want to clone a form and then have the option to remove the form that I have just created. I know how to clone it, but not how to remove it. I have only be able to remove the original form, but not the clonned form. This is my code: function duplicate(id) { var elmnt = document.getElementById(id); var cln = elmnt.cloneNode(true); var num = 1; cln.id = id + num; document.body.appendChild(cln); } function remove(id) { var elem = document.getElementById(id); elem.parentNode.removeChild(elem);

Adding event listeners to <li> that are created using javascript

Deadly 提交于 2020-06-26 12:13:32
问题 I am quite new to manipulating elements in the DOM in JS so I am creating a simple to do list to get more comfortable and where I can add items using the input and remove items by clicking on the list item. ALthough this may not be best practice and limitting I am just wanting to use create and remove elements rather than using objects or classes until I get more familar, also using plain/vanilla js so please keep this in mind when answering. I am trying to add a click event which removes the

Remove sequential <br> in div filled by CMS users via rich text editors

时光怂恿深爱的人放手 提交于 2020-01-25 12:52:47
问题 I have div-area which is filled by CMS users and sends data via a rich text editor. How can I remove sequential br tags more than two in a <div> using jQuery? I tried parent() , closest() but it didn't work. For example, a CMS user added this HTML code using a rich text editor. <div class="cms-data"> <br> <span> <br><br><br><br><br><br> <a href="/uploads/755/a1.xls" target="_blank">xls</span></a> <br><br><br> </span> <br><br> </div> Edit: I added a class name to the <div> , cms-data. 回答1:

How to change root of a node with DomDocument methods?

眉间皱痕 提交于 2020-01-11 07:31:10
问题 How to only change root's tag name of a DOM node? In the DOM-Document model we can not change the property documentElement of a DOMElement object, so, we need "rebuild" the node... But how to "rebuild" with childNodes property? NOTE: I can do this by converting to string with saveXML and cuting root by regular expressions... But it is a workaround, not a DOM-solution. Tried but not works, PHP examples PHP example (not works, but WHY?): Try-1 // DOMElement::documentElement can not be changed,

PHP DomDocument : How remove a div?

别说谁变了你拦得住时间么 提交于 2020-01-04 15:13:31
问题 Here is my code : $doc = new DOMDocument(); $doc->loadHTML(stripslashes($sContent)); // si le meta existe alors il y a un sondage if($doc->getElementById('meta') != null){ $nombreMeta = $doc->getElementById('meta')->nodeValue; $numSondage = $doc->getElementById('meta')->getAttribute('class'); for($i=0;$i<$nombreMeta;$i++){ $meta = $meta."0,"; } $meta = substr($meta,0,-1); $divMeta = $doc->getElementById('meta'); $oldchapter = $doc->removeChild($divMeta); $oHead = $doc->getElementsByTagName(

Internet explorer and removeChild()

妖精的绣舞 提交于 2020-01-04 08:29:12
问题 I have been using elem.removeChild() to remove elements from my document, but saving a JavaScript reference to that element, so that I can add them back when appropriate. Works just fine in Firefox and Chrome. Now I notice that that on IE7, those elements get destroyed in the process, having all their children removed. When I add them back to the same parent element, they are the same type of element and have retained things like their class name, but they have no children elements. Is this

Internet explorer and removeChild()

别来无恙 提交于 2020-01-04 08:29:08
问题 I have been using elem.removeChild() to remove elements from my document, but saving a JavaScript reference to that element, so that I can add them back when appropriate. Works just fine in Firefox and Chrome. Now I notice that that on IE7, those elements get destroyed in the process, having all their children removed. When I add them back to the same parent element, they are the same type of element and have retained things like their class name, but they have no children elements. Is this

Why does removeChild need a parent node?

删除回忆录丶 提交于 2019-12-29 05:57:06
问题 After answering this question I am left wondering why removeChild needs a parent element. After all, we could simply do node.parentNode.removeChild(node); As the parent node should be always directly available to the Javascript/DOM engine, it is not strictly necessary to supply the parent node of the node that is to be removed. Of course I understand the principle that removeChild is a method of a DOM node, but why doesn't something like document.removeNode exist (that merely accepts an