WordPress.org

Ready to get started?Download WordPress

Forums

FadeIn Effect using Jquery (3 posts)

  1. nlex
    Member
    Posted 4 years ago #

    Hello. I'm tryin to put a fade in effect onload of the images of my post, using the jQuerty that comes with WP.

    So i have this in my Header.php :

    <?php wp_enqueue_script('fade', '/javascript/fadein.js', array('jquery')); ?>

    Then the folowing JS in a file : :

    function fade() {
    jQuery('#Picture').load(function(){jQuery("#Picture").fadeIn(600);})
    }

    Then in my post the image is like :

    <img src="http://www.…hop_03.jpg" id="Picture" width="648" height="486" border="0"  />

    But it gives no results. Any idea ?

  2. stvwlf
    Member
    Posted 4 years ago #

    You have to enqueue jQuery itself, before enqueing your script. First, did you do that?

    <?php
    wp_enqueue_script('jquery');
    wp_enqueue_script('fade', '/javascript/fadein.js', array('jquery'));
    ?>

    also, those lines must be located BEFORE
    <?php wp_head(); ?>
    in your theme's header.php file

    First please confirm you have that in place and working.

  3. nlex
    Member
    Posted 4 years ago #

    Thanks a lot for your help.

    No i haven't done that. I was suspecting something like this but i think the WP document doesn't mention it ? Or maybe i just didn't understood…
    Anyway when i look in Safari developement tools (similar to FIreBug or such), i can see the loaded script and i see it loads both jQuery and my 'fade' miniscript so i'm not sure thats the problem…

    Anyway i added the line :
    <?php wp_enqueue_script('jquery');?>
    (of course before end of 'head')

    But, that doesn't help ! :(

    if you want to check by yourself :
    http://alturl.com/pjwp
    The 1st image should fadein (i know i have a bug in my sidebar but… one things after another…)

Topic Closed

This topic has been closed to new replies.

About this Topic