javascript - trying to change the text of the button without editing the html code -


i'm trying change text of button without editing html code doesn't work

here code:

document.queryselector(".game-button").onclick = function knop(knop) {     document.queryselector(".game-button").innerhtml = "reset spel"; } 

html:

<button class="game-button">start spel</button> 

if may suggest:

var gamebutton = document.queryselector(".game-button") gamebutton.onclick = function() {     gamebutton.innerhtml = "reset spel"; } 

i've put gamebutton in variable referenced once. since function connected onclick event, naming function not needed. also, not passing or using arguments, there no need put between ().


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -