首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为什么这段html不能识别我的javascript函数?

为什么这段html不能识别我的javascript函数?
EN

Stack Overflow用户
提问于 2019-06-13 07:09:05
回答 1查看 1K关注 0票数 0

我正在使用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代码应该获取输入字段并使用它们更新图表。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56571430

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档