• I’m trying to include the jQuery library and trigger my script (tested and working on standard HTML page), but not having any luck. Can anybody help… it’s driving me nuts?

    I’ve scoured the forums and Google and tried everything that I’ve come across, but it’s just not happening.

    This is what I’ve currently got i the header.php:

    I have placed this:

    <?php wp_enqueue_script('jquery'); ?>
    <?php wp_enqueue_script('myjsfile', '/wp-content/themes/my-theme/js/myjsfile.js', array('jquery')); ?>
    
    <script type="text/javascript">
    jQuery(document).ready(function() {
    jQuery('.rOver').myjsfile({speed: 100, delay: 400});
    });
    </script>

    Immediately before this:

    <?php wp_head(); ?>

Viewing 5 replies - 16 through 20 (of 20 total)
  • thanks to everyone that posted. you guys really helped me.well done!!!

    jtancil

    (@jtancilyahoocom)

    was having the same problems as others on this thread. I followed inetwerx’s suggestions (enqueue and replace all $ with jQuery) and the script worked again. thank you!!!

    harrybargis

    (@harrybargis)

    This is why I love the wordpress forum. Came here to ask the same question and find all the answers I need. Thanks everyone.

    Harry

    Gerald Yeo

    (@geraldyeo)

    Just a small tip:

    I was reading through the thread and noticed that many are taking to replacing all $ signs within the code. You don’t need to change all the $ sign to jQuery in your code…

    You just need to wrap all your code within

    jQuery(document).ready(function($) {
     //code.
    });

    Note the $ in the function bracket which alot of examples above miss out.

    All the $ within your code would still be interpreted correctly.

    Cheers!

    Excellent info. This solved a problem I’ve spent weeks researching. I added

    <?php wp_enqueue_script(“jquery”); ?>
    <?php wp_head(); ?>

    and then followed geraldyeo’s suggestion above. I then watched in wonder as I saw javascript doing what it’s supposed to do. Thank you for giving me my time back to tackle the next coding mystery. Til we commiserate and solve again!

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Include jQuery in header.php… PLEASE HELP ?!’ is closed to new replies.