简体   繁体   English

如何在Wordpress上正确包含jquery-ui效果

[英]How to correctly include jquery-ui effects on wordpress

I've been trying to include the jquery ui effects (more specifically the shake effect) on my wordpress theme. 我一直在尝试在我的wordpress主题中包括jquery ui效果(更具体地说是摇动效果)。 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. 到目前为止,我只能包含jQuery脚本,但是我真的不知道将ui脚本放置在何处以及如何使其入队。

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>

Thanks for your help! 谢谢你的帮助!

It might be possible that the jquery-ui-core included with wordpress does not include Effects. wordpress附带的jquery-ui-core可能不包含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. 该文档尚不清楚( http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress )您可能必须从URL加载自定义jquery-ui程序包。 Below will load full jquery UI from google cdn 下面将从谷歌cdn加载完整的jQuery UI

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

You can also use the wp_enqueue_script($name, $src) function to load your own scripts. 您还可以使用wp_enqueue_script($ name,$ src)函数加载自己的脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM