+ 1
My browser is not display. I want to do input change évent with updateValue. Thanks you sir.
input event listener updateValue. https://code.sololearn.com/WNG6iE4O39uj/?ref=app
3 ответов
+ 2
// There are a few problems. I strongly recommend to repeat JavaScript tutorial and learn the kanguage basics from more sources.
input.addEventListener ("input",function (e) {
const input = document.querySelector ("input");
const log = document.getElementById ("log");
log.innerText = e.target.value;
});
+ 2
Your code is not in readable form, try to make it readable.
+ 1
window.onload = () =>{
//begin structure
var input = document.createElement ("input");
input.placeholder = "Enter some text";
document.body.appendChild(input)
//p
var p = document.createElement ("p");
//set id
p.setAttribute ("id","log");
//document
document.body.appendChild(p);
//end structure
input.oninput = updateValue;
//document
document.body.appendChild (input );
//event
input.addEventListener("change", updateValue)
function updateValue(e) {
const input = document.querySelector("input");
const log = document.getElementById ("log");
log.innerText = input.value;};
}