WordPress.org

Support

Support » Themes and Templates » [Resolved] [Q&A] add jquery problem

[Resolved] [Q&A] add jquery problem

  • 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

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

    @anevins

    Forum moderator

    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 :<

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    So it’s not loading at all?

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

    Moderator Andrew Nevins

    @anevins

    Forum moderator

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

    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” ?

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    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>

    ?

    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 ?

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    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.

    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 !!!

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

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    It’s marked resolved, thanks.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Resolved] [Q&A] add jquery problem’ is closed to new replies.