DOM Controls that do things
Jump to navigation
Jump to search
When the user clicks the button the DOM gets changed.
let b = document.createElement('button'); b.innerText = 'click me'; b.onclick = ()=>{ document.body.append('Hello world'); } document.body.append(b);
let b = document.createElement('button'); b.innerText = 'click me'; b.onclick = ()=>{ document.body.append('Hello World!'); } document.body.append(b);
The user can change the text that gets echoed.
let i = document.createElement('input'); i.value = 'Andrew was here'; let b = document.createElement('button'); b.innerText = 'click me'; b.onclick = ()=>{ document.body.append(i.value); } document.body.append(i,b);
let i = document.createElement('input'); i.value = 'Andrew was here'; let b = document.createElement('button'); b.innerText = 'click me'; b.onclick = ()=>{ document.body.append(i.value); } document.body.append(i,b);