Print with setInterval in the same place

2

I need to make sure that when "filling ..." is printed by setInterval , it's exactly the same place as the first impression. It turns out you're going down or forward. Is there any way to do this, print several times in the same place in 3 and 3 seconds without leaving there border ?

var x = setInterval(function(){

$('div').append('<p id="demo1">Preenchendo...</p>')

}, 1000)
#demo{
    border: 1px solid black;
    height: 50px;
    width: 400px;
    text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><html><body><span><h4>Espaçoembranco</h4></span><divid="demo"></div>

</body>
</html>
    
asked by anonymous 02.09.2017 / 02:10

1 answer

3

Instead of% with% use% with%. And for it to be every 3 seconds, just set the interval to append . See:

var x = setInterval(function() {

  $('div').html('<p id="demo1">Preenchendo...</p>')

}, 1000)
#demo {
  border: 1px solid black;
  height: 50px;
  width: 400px;
  text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><html><body><span><h4>Espaçoembranco</h4></span><divid="demo"></div>

</body>
</html>
    
02.09.2017 / 02:14