How to replace HTML element with JavaScript element or clone of it? -
How to replace the HTML element with the JavaScript element or its clone (without deleting the HTML element)? I was wasting a lot of time trying to make javascript:
-
Clone the HTML text box / create new JS textbox
-
Change the JS text box without removing the HTML text box to the HTML text box / without leaving the clone of the HTML text box.
I can not find the solution.
Here the code is - & gt; I'm getting into
[object HTMLInputElement] output ...
& lt; Script src = "// ajax.googleapis.com/ajax/libs/jquery/ 1.11.0 / jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Html lang = "en" & gt; & Lt; Body & gt; & Lt; Td> & Lt; Input class = "inputtext" name = "first" id = "first" tabindex = "1" type = "text" & gt; & Lt; / Td> & Lt; Td> & Lt; Input class = "inputtext" name = "seconds" id = "seconds" tabindex = "1" type = "text" & gt; & Lt; / Td> & Lt; / Body & gt; & Lt; / Html & gt; & Lt; / Body & gt; & Lt; / Html & gt; & Lt; Script & gt; Function Replacement Goal (target id, html) {var i, div, elm, last, target = document.getElementById (targetID); Div = document.createElement ('div'); Div.innerHTML = html; I = div.childNodes.length; Final = target; While (i -) {target.parentNode.insertBefore ((elm = div.childNodes [i]), last); Last = elm; } /// Delete goal target.parentNode.removeChild (target); } & Lt; / Script & gt; & Lt; Script & gt; Var p = document.getElementById ("before"); Var p_prime = first.cloneNode (true); P_prime.id = "first123" p_prime.name = "first123" p_prime.value = "testtest" document.getElementById ("first"). Append child (p_prime) document.getElementById ('first'). value = 'emailtype @ gmail com'; document.getElementById ('Second'). value = 'LecimyTutaj'; Window.onload = function () {replaceTargetWith ('first', document.getElementById ('first123')); } & Lt; / Script & gt;
I would like to hide an existing HTML text box behind the newly created JavaScript script, or clone created by JavaScript without deleting it. :) Sorry if I wrote something wrong.
I am not on the computer, so it is difficult to add code samples to help you but in general But ... create an HTML model and do not give it a
display: any in the CSS (you will not use this section explicitly, so do not put any values it ... Just to copy and paste). Give it an ID like "myModel" so you can do it on that model and add it as often as you would like as a child of some containers. Fill these sticky examples with whatever you want.
If anyone does not offer you more useful help in the next few hours, then I will add a code sample when I am somewhere other than my phone.
Comments
Post a Comment