开发者

How to correctly include jquery-ui effects on wordpress

开发者 https://www.devze.com 2023-02-05 23:03 出处:网络
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 wher

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.

开发者_JS百科

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. 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"); ?>

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

0

精彩评论

暂无评论...
验证码 换一张
取 消