我有一个带有下拉列表的index.pug,当用户选择下拉列表中的任何值时,我希望显示警告窗口。当我从下拉列表中选择任何值时,我的commandLine.js和index.pug在同一个directory.But中,警告消息没有显示。我使用onChange函数来调用myFunction()方法。我尝试了很多事情,但没能解决问题。我不确定script(src="commandLine.js")是否是在.pug文件中链接脚本的正确方式。任何帮助都会很感激的。
index.pug
doctype html
html
head
script(src="commandLine.js")
body
h1 Intelligent State Space Pruning
br
form
div
label Samplertype
select#samplertype(onchange='myFunction()')
option(value='', selected='', disabled='', hidden='') Samplertype
option(value='Monte Carlo Simulation ') Monte Carlo Simulation
option(value='Latin Hypercube Sampling') Latin Hypercube Sampling
option(value='Descriptive Sampling ') Descriptive Sampling
option(value='Halton Sampling ') Halton SamplingcommandLine.js
function myFunction()
{
alert('hi');
}发布于 2018-03-12 19:10:45
您正在调用赋值中的函数。你必须分配它。
select#samplertype(onchange='myFunction')发布于 2018-03-14 15:02:53
使用script(type="text/javascript" scr='javascripts/commandLine.js')解决了这个问题
https://stackoverflow.com/questions/49242561
复制相似问题