Support » Fixing WordPress » Implementing jQuery in Header

  • Dear all, i have been trying to get a jQuery script to work on my wp site for 2 days now and it’s driving me nuts. Hope someone here can help.
    Basically i am trying to add jQuery Image Hover effect via the widget area using th text widget.

    I DONT SEEM TO ADD THE JQUERY CODE PROPERLY IN THE HEAD.PHP…..

    Here is the code i am working with:

    $(document).ready(function(){
    //To switch directions up/down and left/right just place a “-” in front of the top/left attribute
    //Vertical Sliding
    $(‘.boxgrid.slidedown’).hover(function(){
    $(“.cover”, this).stop().animate({top:’-260px’},{queue:false,duration:300});
    }, function() {
    $(“.cover”, this).stop().animate({top:’0px’},{queue:false,duration:300});
    });
    //Horizontal Sliding
    $(‘.boxgrid.slideright’).hover(function(){
    $(“.cover”, this).stop().animate({left:’325px’},{queue:false,duration:300});
    }, function() {
    $(“.cover”, this).stop().animate({left:’0px’},{queue:false,duration:300});
    });
    //Diagnal Sliding
    $(‘.boxgrid.thecombo’).hover(function(){
    $(“.cover”, this).stop().animate({top:’260px’, left:’325px’},{queue:false,duration:300});
    }, function() {
    $(“.cover”, this).stop().animate({top:’0px’, left:’0px’},{queue:false,duration:300});
    });
    //Partial Sliding (Only show some of background)
    $(‘.boxgrid.peek’).hover(function(){
    $(“.cover”, this).stop().animate({top:’90px’},{queue:false,duration:160});
    }, function() {
    $(“.cover”, this).stop().animate({top:’0px’},{queue:false,duration:160});
    });
    //Full Caption Sliding (Hidden to Visible)
    $(‘.boxgrid.captionfull’).hover(function(){
    $(“.cover”, this).stop().animate({top:’160px’},{queue:false,duration:160});
    }, function() {
    $(“.cover”, this).stop().animate({top:’260px’},{queue:false,duration:160});
    });
    //Caption Sliding (Partially Hidden to Visible)
    $(‘.boxgrid.caption’).hover(function(){
    $(“.cover”, this).stop().animate({top:’160px’},{queue:false,duration:160});
    }, function() {
    $(“.cover”, this).stop().animate({top:’220px’},{queue:false,duration:160});
    });
    });

    Can anyone help please.

Viewing 1 replies (of 1 total)
  • Don’t add it in head.php. Create a separate javascript file in your theme root (we’ll call it my.js for the example) and put all your js in there. Then, in your functions.php add:

    add_action('wp_enqueue_scripts','enqueue_my_javascript');
    function enqueue_my_javascript() {
    wp_register_script('my.js','my.js');
    wp_enqueue_script('my.js');
    }

    You need to hook javascript file calls to wp_enqueue_scripts (outside of the admin section). Make sense?

Viewing 1 replies (of 1 total)
  • The topic ‘Implementing jQuery in Header’ is closed to new replies.