Intr-un responseText am:
Cod: Selectaţi tot
<div id="output">
<h4>Some Title</h4>
<p>Some Text</p>
<b>Some Bold Text</b>
</div>
Fara sa folosesc innerHTML cum pot sa pun contentul lui <div id="output"> in <div id=""targetDiv">?
In exemplu de mai jos ce lipseste pentru a fi functionabil?
Cod: Selectaţi tot
function inHtml(fromId,toId) // inlocuieste InnerHTML
{
var fromNode=document.getElementById(fromId);
var toNode=document.getElementById(toId);
if (toNode.hasChildNodes())
{
while(toNode.childNodes.length >= 1)
toNode.removeChild(toNode.firstChild );
}
for(var n=0; n<fromNode.childNodes.length; n++)
toNode.appendChild(fromNode.childNodes[n].cloneNode(true));
}
xhr.responseText;
// ce trebuie sa fac ca <div id="output"> sa fie gasit in linia urmatoare?
inHtml('output','targetDiv')