我正在使用WordPress中的一个函数呈现一个包含两个输入字段的图形。js文件对于html的这一部分绝对是可用的,因为图形正在呈现。它是通过wp中的enqueue_script函数包含的。但是,当我尝试设置onclick函数(updateChart())时,我得到一个错误,指出我的函数没有定义。已经有一段时间了.有什么想法吗?
我已经尝试将脚本directl导入到我试图调用它的标签上方的head中。
ob_start();?>
<head>
<!–– All styling should take place below ––>
<!–– First div id must match the first argument of Chart Object in js file ––>
</head>
<body>
<div id='chartContainer' style='height: 300px; width: 100%;'></div>
<input type='number' id='voltage' placeholder='Voltage' step='0.01' />
<input type='number' id='amperage' placeholder='Amperage' step='0.01' />
<button id ='simulate' onclick= 'updateChart()' >Simulate</button>
</body>
<?php
$content = ob_get_clean();
echo($content);
}
js代码应该获取输入字段并使用它们更新图表。
https://stackoverflow.com/questions/56571430
复制相似问题