• Resolved Corneliatt

    (@corneliatt)


    Hi!
    I have this small script to do a roll-over effect on my divs:

    jQuery(".posts").hover(function() {
      jQuery(this).children(".headline").stop().fadeTo("fast", 1.0);
    }, function() {
      jQuery(this).children(".headline").stop().fadeTo("fast", 0);
    });

    It works just fine when using it here:
    http://jsfiddle.net/Hec79/

    But as soon as I use it together with the included jquery in WordPress, it stops working. Does anybody know why this happens?

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you put it inside document.ready()?

    Corneliatt,

    Andrew Nevins response is correct. Initialize the script on document ready like so:

    jQuery(document).ready(function(){
        jQuery(".posts").hover(function() {
      jQuery(this).children(".headline").stop().fadeTo("fast", 1.0);
    }, function() {
      jQuery(this).children(".headline").stop().fadeTo("fast", 0);
    });
        });
    Thread Starter Corneliatt

    (@corneliatt)

    Ohh for a moment I thought that could be the solution! But I can’t get it to work even with the document ready function. Could there be somehing else that keeps it from working?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you use an inspector tool, such as the one built-in to Google Chrome browser, to find ‘console’ errors and tell is what errors are displaying?

    Thread Starter Corneliatt

    (@corneliatt)

    I’m almost embarrased to tell you the error.

    I was totally focused on the script and really thought it was something wrong there. But the error was due to spaces in my theme name on the server…..

    Thanks to both of you for trying to solve this none existing jquery error!! >_<

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can't get my jquery to work on this simple script’ is closed to new replies.