[英]Getting alert to pop up
This is the HTML Code这是 HTML 代码
<p>
filename:
<input type="text" id="finput">
<input type="button" value="upload" onclick:"uploadText()">
</p>
This is the javascript function I tried to write and call:这是我尝试编写和调用的 javascript 函数:
function uploadText(){
var textinput= document.getElementById("finput");
var userinput= textinput.value;
alert ("you chose" + userinput);
};
I'm not sure whats wrong.我不确定出了什么问题。 When I click the button, there is no response or alert.当我单击按钮时,没有响应或警报。 I am using codepen do write this code.我正在使用 codepen 编写此代码。 Any insight into what I'm doing wrong?对我做错了什么有任何见解吗?
here is a link to the codepen : https://codepen.io/sophiesucode/pen/qBEoOEV这是代码笔的链接: https ://codepen.io/sophiesucode/pen/qBEoOEV
In html, you assign with an equal sign (=) and here you have a colon (:) in the assignment of the event handler.在 html 中,您使用等号 (=) 进行分配,而此处您在事件处理程序的分配中使用冒号 (:)。
Colons are used in CSS styles but not HTML.冒号用于 CSS 样式,但不用于 HTML。 Change it to an equal sign and it works.将其更改为等号,它就可以工作了。
<input type="button" value="upload" onclick="uploadText()">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.