gpt4 book ai didi

javascript - 烦人的是 this.refresh() 不是 Firefox 中的函数

转载 作者:行者123 更新时间:2023-12-02 20:25:32 25 4
gpt4 key购买 nike

这是我的问题的解决方案。我可以显示一个字段,输入一个新值,再次单击该字段,然后使该字段随着新值消失。每当 this.refresh() 不是一个函数时,Firefox 错误控制台都会提示。

如何消除 this.refresh() is not a function 错误,以便我可以清除 Firefox 控制台并查找实际导致问题的错误?

var gotIt='no'

function askName(x)
{if(gotIt=='yes')
{response=this.name
characters[x].setName(response)
gotIt='no'
}
else
{gotIt='no'
this.name=characters[x].name
response="<input onClick=_setName(this.value) size=10 type=text value="+this.name+">"
characters[x].setName(response)
}
}
function _setName(x)
{this.name=x
this.refresh()
gotIt='yes'
}

最佳答案

您的代码中几乎所有内容都是错误的,以下代码可以满足您的需要。如果你想理解 JavaScript,你需要努力。

enter image description here

<!doctype html>

<html>
<head>
<script>
window.onload = function () {
var input = document.createElement ("input");
var span = document.getElementsByTagName ("span")[0];

input.addEventListener ("blur", function () {
span.innerHTML = this.value;
}, false);

span.addEventListener ("click", function () {
if (this.getElementsByTagName ("input").length === 0) {
input.value = this.textContent;

this.innerHTML = "";

this.appendChild (input);

input.focus ();
}
}, false);
}
</script>

<style>
span {
font-weight: bold;
}
</style>

<title></title>
</head>

<body>
<span>Braveheart</span>
</body>
</html>

关于javascript - 烦人的是 this.refresh() 不是 Firefox 中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4907319/

25 4 0
文章推荐: javascript - 交换
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com