首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我需要帮助添加一些JavaScript代码到我的wordpress主题

我需要帮助添加一些JavaScript代码到我的wordpress主题
EN

Stack Overflow用户
提问于 2015-02-04 11:14:07
回答 1查看 102关注 0票数 2

我知道我必须将鼠标指针javascript保存在我的主题库中,我是否也将函数javascript保存在我的主题库中?如果我说得不够清楚,很抱歉,如果这让人困惑,请评论!

代码语言:javascript
复制
jsfiddle.net/ctLevz8L/59/
EN

回答 1

Stack Overflow用户

发布于 2015-02-04 12:18:11

从您的小提琴中取出javascript并将其保存到wp-content/themes/mytheme/js/hoverintent.js

然后,将以下内容添加到主题的functions.php文件中:

代码语言:javascript
复制
function enqueue_hoverintent {
    //Add the script and jquery-ui to the generated header.
    wp_enqueue_script(
        'my_hoverintent', 
         get_stylesheet_directory_uri() . '/js/hoverintent.js', 
         array('jquery-ui-core')
    );

    //Add the jqueryui css file from Google's CDN since it isn't included with WP
    wp_enqueue_style (
        'googlecdn_jqueryui_style',
         'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css',
    );
}

add_action( 'wp_enqueue_scripts', 'enqueue_hoverintent' );
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28312904

复制
相关文章

相似问题

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