Onclick function “is not defined”

前端 未结 4 564
没有蜡笔的小新
没有蜡笔的小新 2020-12-28 20:08

I am fairly new to wordpress and am trying to define and call a function but cannot get it to work.

The following code appears in a php file that is called from the

4条回答
  •  孤独总比滥情好
    2020-12-28 20:35

    What you wrote is a Javascript function, it must be surrounded by in HTML code. Have you written your function in something like:

    echo('');
    

    Also, I think Wordpress must have some function ready to use to add scripts. Try to have a look on wp_enqueue_script (string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, bool $in_footer = false);

    edit: I just found that question, it may answer yours: How to write a Javascript function inside the functions.php of Wordpress?

提交回复
热议问题