0

When i try to replace string 0,50 with javascript 'mydiv' has been deleted/moved

Example

<div id="para1"><div class="mydiv"></div>0,50</div>

When i try to replace 0,50 by 80 i do :

document.getElementById("para1").innerText = "80"

or with jQuery

$("#para1").text("80")

then the result is :

<div id="para1">80</div>

during the operation it delete <div class="mydiv"></div>

How can i do to keep structure of html and result like this :

<div id="para1"><div class="mydiv"></div>80</div>
almeidaz
  • 11
  • 4
  • are you tried something like `+=` – Laaouatni Anas Dec 25 '21 at 12:40
  • Familiarize yourself with the [DOM API](//developer.mozilla.org/docs/Web/API/Document_Object_Model): [`childNodes`](//developer.mozilla.org/docs/Web/API/Node/childNodes), [`Text`](//developer.mozilla.org/docs/Web/API/Text), [`textContent`](//developer.mozilla.org/docs/Web/API/Node/textContent). – Sebastian Simon Dec 25 '21 at 12:42

0 Answers0