javascript - Why does span tag under div disappear when jQuery refreshes the data div -


$(document).ready(function() {    setinterval(function() {      $.get("temp.php", function(temp) {        $("deneme span").html(temp);        $("#deneme").html(temp);        });    }, 3000);  });
<div class="container">    <div class="de">      <div class="den">        <div class="dene">          <div class="denem">            <div class="deneme" id="deneme">              <span></span><strong>&deg</strong>            </div>          </div>        </div>      </div>    </div>  </div>    </center>

that's because .html() replaces html inside div.

so $("deneme span").html(temp); trying fill-up span, $("#deneme").html(temp); removing whole content , replacing temp.

i suggest use .append() add div.


Comments