![](/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.