![](/img/trans.png)
[英]Why does the onclick function run on onclick, but not when I call it manually?
[英]why does Onclick=“function()” shows up 404 when I am trying to run a function in node?
单击提交按钮时,我正在尝试运行displayitor功能。 但是,在网页上,单击按钮时会显示404。 似乎无法弄清楚为什么这样做。 我正在使用node.js。 玉快递。
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';
表单内的按钮默认会在单击时提交表单,使用e.preventDefault()
或return false;
以防止这种行为。
尝试如下重写您的Jade文件。 这里有一些错误:
这是工作代码:
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.