首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >确认弹出窗口,说明未定义且未更改段落

确认弹出窗口,说明未定义且未更改段落
EN

Stack Overflow用户
提问于 2017-03-12 02:29:45
回答 1查看 47关注 0票数 1

我有一个确认弹出窗口,说不确定在哪里应该说消息‘按下OK或取消’,然后段落应该改变为“你点击了ok”或“你点击了取消”。

有人能解释一下为什么会发生这种情况以及如何修复吗?非常感谢

代码语言:javascript
复制
@charset "UTF-8";
/* CSS Document */

body{
	height:1000px;
	width:100%;
	background:#fff;
	margin:0;
}

.divider{
	width:100%;
	height:auto;
	background:#CCC;
	display:block;
	margin:10px;
}

h2{
	font-size:16px;
	display:block;
}
#confirm-paragraph{}
#global-variable-paragraph{}
#user-input{}
#expressions{}
#elephant-paragraph{}
#method-1{}
#method-2{}
#ml{}
#litres{}
#conditional-operator{}
#cast-1{}
#cast-2{}
代码语言:javascript
复制
<!-- Checklist: Confirm Example -->
<!-- Checklist: Local Variables -->
<section class="divider">
<h2>Confirm Example</h2>
<button onclick="confirm()">Click Me</button>
<p id="confirm-paragraph">This text should change after clicking the button.</p>
<p style="color:red; font-weight:bold">NOT WORKING Version 1!!!!!!!!</p>
<p>Undefined should instead say "Press OK or Cancel".</p>
<p>And text should change to either "you clicked ok" or "you clicked cancel"</p>
<script>
function confirmFunction() {
	var textentry;
	var confirmation = confirm('Press OK or Cancel');
	if (confirmation == true) {
		textentry = "You clicked OK";
	} else {
		textentry = "You clicked Cancel";
	}
	document.getElementById("confirm-paragraph").innerHTML = textentry;
}
</script>
</section>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-12 02:33:05

您的单击引用了错误的函数:

代码语言:javascript
复制
<button onclick="confirm()">Click Me</button>

应该是

代码语言:javascript
复制
<button onclick="confirmFunction()">Click Me</button>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42739003

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档