Javascript: How do I refresh text values -


<script> function balancerefresher() {     <b>balance:      document.write(playerbalance)     </b>     } setinterval(balancerefresher, 1000); </script> 

obviously, isn't actual code, i'm trying refresh variable 'playerbalance' in text. have no idea other way in, complete beginner javascript.

document.write, name suggests writes document, if want dynamically modify , element on display create placeholder , access element , modify, example, in document create placeholder:

    <div id="any_id"></div> 

then in javascript:

    let el = document.getelementbyid("any_id");      if ( el ) {         if ( el.haschildnodes() ) {             el.removechild(el.childnodes[0]);         }         el.appendchild(document.createtextnode("your text"));     } 

https://www.w3schools.com/jsref/met_document_getelementbyid.asp


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -