function replace_element_by_html(ele, html){ var newEle=ele.cloneNode(false); newEle.innerHTML=html; ele.parentNode.insertBefore(newEle, ele); ele.parentNode.removeChild(ele); }