【发布时间】:2021-04-30 23:24:54
【问题描述】:
我正在用 HTML 制作一个计算器。我想使用清除按钮清除结果。但这件事不起作用。
这是清除按钮的 HTML 代码:
<button onclick="clear()">C</button>
这是我的这个函数的 Javascript 代码:
function clear()
{
document.getElementById('text').innerHTML=" ";//text is the ID of the paragraph tag which holds the string which the user has passed
document.getElementById('answer').innerHTML=" ";//answer is the ID of the paragraph tag which shows the answer
}
请帮帮我。提前致谢!!
【问题讨论】:
-
您发布的代码看起来不错。请分享更多上下文
-
ID 匹配吗?看不到任何错误
-
感谢大家的建议和关注,但我知道这件事与我的休息代码一起工作。 mpm给出的答案帮我解决了问题。
标签: javascript