[英]javascript function not working in node.js Jade express
這是我的代碼:
extends layout
block content
h1= title
div(id="rename", class="Name", onload='name("rename", "editor")')
form(id = "filename", method ="post")
input(id="new_name", type ="text", placeholder="File Name")
input(id="Okay", type="submit", value="Okay")
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 name(id, id2){
document.getElementById(id).style.display = 'block';
document.getElementById(id2).style.display = 'none';
//document.getElementById(id3).style.display = 'none';
}
當我在網絡上運行它時,沒有調用我的javascript函數。 我似乎無法弄清楚為什么,但是我認為這與語法有關。 我認為我在調用函數時沒有使用正確的引號。
這是我在Web瀏覽器上檢查元素時的外觀。
您需要在<body>
上設置onload
屬性,而不是其他任何標簽。 或者,您可以在頁面上添加一小段javascript以執行相同的操作:
window.onload = function() { name("rename", "editor"); });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.