如何在Wordpress上正确包含jquery-ui效果 [英] How to correctly include jquery-ui effects on wordpress

查看:110
本文介绍了如何在Wordpress上正确包含jquery-ui效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在我的wordpress主题中包括jquery ui效果(更具体地说是摇动效果).到目前为止,我只能包含jQuery脚本,但是我真的不知道将ui脚本放置在何处以及如何使它们入队.

I've been trying to include the jquery ui effects (more specifically the shake effect) on my wordpress theme. So far, I've only been able to include the jQuery script, but I really have no clue where to place the ui scripts and how to enqueue them.

这是我的代码.显然不起作用:

This is the code I have. It obviously doesnt work:

    <?php wp_enqueue_script("jquery"); ?>
<?php wp_enqueue_script("jquery-ui-core"); ?>
<?php wp_head(); ?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
<script type="text/javascript">
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
        $j("#manita-imagen").mouseover(function(){
            //$j(this).animate({ opacity: "hide" })
            // alert('asd');
            $j(this).effect("shake", { times:3 }, 300);
        });
    });

 </script>

感谢您的帮助!

推荐答案

wordpress附带的jquery-ui-core可能不包含Effects.该文档尚不清楚( http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress)您可能必须从URL加载自定义jquery-ui程序包.下面将从Google CDN加载完整的jQuery UI

It might be possible that the jquery-ui-core included with wordpress does not include Effects. The documentation is unclear(http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress) You might have to load a custom jquery-ui package from a url. Below will load full jquery UI from google cdn

<?php wp_enqueue_script("myUi","https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js"); ?>

您还可以使用wp_enqueue_script($ name,$ src)函数来加载自己的脚本.

You can also use the wp_enqueue_script($name, $src) function to load your own scripts.

这篇关于如何在Wordpress上正确包含jquery-ui效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆