[英]why does Onclick=“function()” shows up 404 when I am trying to run a function in node?
I am trying to run the function displayeditor, when I click the submit button. 单击提交按钮时,我正在尝试运行displayitor功能。 However on the webpage it shows 404 when the button is clicked.
但是,在网页上,单击按钮时会显示404。 Can't seem to figure out why it does that.
似乎无法弄清楚为什么这样做。 I am using node.js.
我正在使用node.js。 jade express.
玉快递。
extends layout
block content
h1= title
div(id="rename", class="Name")
form(id = "filename", method ="post")
input(id="new_name", type ="text", placeholder="File Name")
input(id="Okay", type="submit", value="Okay", onclick="displayeditor('editor', 'rename')")
div(id="editor")
|Welcome to the home pages
|This is the first Paragraph
script(src="javascripts/ace.js", type="text/javascript")
script.
var editor=ace.edit("editor")
script(src="/jvm.js", type="text/javascript")
script.
function displayeditor(id, id2)
document.getElementById(id).style.display = 'block';
document.getElementById(id2).style.display = 'none';
//document.getElementById(id3).style.display = 'none';
The button inside the form will submit the form by default on click, use e.preventDefault()
or return false;
表单内的按钮默认会在单击时提交表单,使用
e.preventDefault()
或return false;
to prevent the behaviour. 以防止这种行为。
Try rewriting your Jade file as follows. 尝试如下重写您的Jade文件。 There were a few errors here:
这里有一些错误:
Here's the working code: 这是工作代码:
extends layout
block content
h1= title
div(id="rename", class="Name")
form(id = "filename", method ="post")
input(id="new_name", type ="text", placeholder="File Name")
input(id="Okay", type="submit", value="Okay", onclick="displayeditor('editor', 'rename')")
div(id="editor")
|Welcome to the home pages
|This is the first Paragraph
script(src="javascripts/ace.js", type="text/javascript")
script.
var editor=ace.edit("editor");
script(src="/jvm.js", type="text/javascript")
script(type="text/javascript").
function displayeditor(id, id2) {
document.getElementById(id).style.display = 'block';
document.getElementById(id2).style.display = 'none';
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.