Javascript 追加的文本立即出现
当我在chrome扩展弹出窗口中向div添加文本时,文本会出现几秒钟,然后立即再次出现 这是一个小例子:Javascript 追加的文本立即出现,javascript,google-chrome-extension,Javascript,Google Chrome Extension,当我在chrome扩展弹出窗口中向div添加文本时,文本会出现几秒钟,然后立即再次出现 这是一个小例子: <html> <head> <script> function show() { var newName = document.showMe.textToShow.value; var txt = document.createTextNode(newName); document.g
<html>
<head>
<script>
function show() {
var newName = document.showMe.textToShow.value;
var txt = document.createTextNode(newName);
document.getElementById("feedback").appendChild(txt);
}
</script>
</head>
<body>
<form name="showMe">
Name: <input type="text" name="textToShow" /><br />
<input type="submit" value="Show" OnClick="show()" />
</form>
<div id="feedback"></div>
</body>
</html>
函数show(){
var newName=document.showMe.textToShow.value;
var txt=document.createTextNode(newName);
document.getElementById(“反馈”).appendChild(txt);
}
名称:
我做错了什么
谢谢
Miel.它可以工作,但是表单会被提交。您必须禁止这样发送表单
<input type="submit" value="Show" OnClick="show(); return false" />
或使用按钮:
<button type="button" onclick="show()">Show</button>
Show
谢谢,这就够了。我已经在想为什么调试器让我一步一步地检查
两次。