我的代码需要一些帮助:
var p = document.getElementById("place-users");
class User {
constructor(name, age, job) {
this.name = name;
this.age = age;
this.job = job;
}
createUser(){
this.name = prompt("Wat is uw naam");
this.age = prompt("Wat is uw leeftijd");
this.job = prompt("Wat is uw beroep");
}
placeUsers() {
p = document.createElement("p");
p.innerHTML = this.name + " " + this.age + " " + this.job;
document.getElementById("place-users").append(p);
}
}
let user = new User("User ", "1 ", "AI");
var showInfo = p.onclick = function() {
alert("Hallo " + user.name)
}
警报发出时,即使我单击其他用户,它也始终显示创建的最新用户吗?
有人知道我做错了吗?