WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Q&A] add jquery problem (13 posts)

  1. mcmillant
    Member
    Posted 11 months ago #

    i used these codes for my wp theme but it doesn't work (it works well in html file)

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    	<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.1.1.min.js"></script>
    	<script type="text/javascript" src="<?php echo bloginfo('template_directory'); ?>/js-file/my-js-1.js"></script>
            <script type="text/javascript" src="<?php echo bloginfo('template_directory'); ?>/js-file/my-js-2.js"></script>

    do i use wrong code?
    thnks for your support

  2. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 11 months ago #

  3. mcmillant
    Member
    Posted 11 months ago #

    it said

    f your custom JavaScript isn't working after including the previous line of code in your header.php template file, use the following line of code.

    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/pathto/yourscript.js"></script>
    Include the leading forward slash "/" even if your file is located in the root of your theme.

    i changed my code
    <?php echo bloginfo('template_directory'); ?>
    to
    <?php bloginfo('template_url'); ?>

    but nothing happen :<

  4. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 11 months ago #

    So it's not loading at all?

  5. mcmillant
    Member
    Posted 11 months ago #

    the site's loading fine but animation effect from js isn't

  6. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 11 months ago #

    You shouldn't need to redeclare jQuery, so remove that. What's the migrate script for?

  7. mcmillant
    Member
    Posted 11 months ago #

    sorry for my poor english. You mean i don't need add

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    	<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.1.1.min.js"></script>

    ????
    and what do you mean "migrate script" ?

  8. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 11 months ago #

    You don't need this;

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

    What is this for;

    <script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.1.1.min.js"></script>

    ?

  9. mcmillant
    Member
    Posted 11 months ago #

    ops, i copied from jquery.com site and forgot remove it
    i removed these codes you said but it still not working, do you think wamp sever is the problem ?

  10. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 11 months ago #

    I think it could be many problems, such as not using noconflict wrappers, not enqueuing your JavaScript, or an issue with the code itself.

    Unless you can demonstrate the issue in a webpage, it is unlikely any of us will be able to help.

  11. mcmillant
    Member
    Posted 11 months ago #

    yea i think so, i used firebug and it said have many problems about my js file
    such as

    Uncaught ReferenceError: jQuery is not defined  (dropmenu.js:167)
    Uncaught ReferenceError: $ is not defined (dropmenu-fix.js:1)
    Uncaught ReferenceError: $ is not defined (top-up.js:1)

    seem the trully problem is in myself -_-
    Thank you for your help, have nice day !!!

  12. mcmillant
    Member
    Posted 11 months ago #

    done, the problem has been solved :D
    thank you for your help,Andrew. It's not helpfull in my case but you give me some great experiences about Jquery using :D
    p/s: how to close solved thread ?

  13. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 11 months ago #

    It's marked resolved, thanks.

Reply

You must log in to post.

About this Topic