【问题标题】:Installing jQuery plugin into wordpress将 jQuery 插件安装到 wordpress 中
【发布时间】:2013-05-11 09:10:22
【问题描述】:

我有一个用户将根据体能测试结果填写的表单,即每分钟俯卧撑、每分钟仰卧起坐、2 英里跑步时间等。此表单正在提交到一个自定义模板页面,该页面也可以正常工作。然而,我想使用this jquery 插件来帮助我验证我的表单。

如何将这样的 jQuery 库添加到 wordpress 中,以便验证我的表单

【问题讨论】:

标签: jquery wordpress forms validation


【解决方案1】:

打开您的 functions.php 并添加以下代码:

//ad our custom Jquery
 function init_js_scripts() {
if (!is_admin()) {
    wp_register_script('jquery', ('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'), false, '');
    wp_enqueue_script('jquery');

    // load a JS file from your  theme: js/theme.js
    //You will need to create js Folder and put your script in there...
    wp_enqueue_script('my_cool_script', get_template_directory_uri() . '/js/cool_script.js', array('jquery'), '1.0', true);
}
    }
    add_action('init', 'init_js_scripts');

【讨论】:

    猜你喜欢
    • 2014-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-07
    • 2020-07-09
    • 2018-01-21
    • 2017-03-10
    • 2012-10-12
    相关资源
    最近更新 更多