WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to use jQuery in wordpress (8 posts)

  1. pinagby
    Member
    Posted 2 years ago #

    I'm writing a pulgin .I want to use jQuery in it .I wrote some codes as flows:
    <script type="text/javascript" src="jQuery.js"></script>>
    <script type="text/javascript" >
    $(document).ready(function(){
    alert("ddd");
    });
    </script>
    These codes were writen in the main page of my plugin ,and the file jQuery.js is put in the same folder with my plugin files,but these codes can't work.
    How to solve the problem?

  2. pinagby
    Member
    Posted 2 years ago #

    Anybody in?

  3. fonglh
    Member
    Posted 2 years ago #

    try jQuery(document).ready... instead of $(document)

  4. pinagby
    Member
    Posted 2 years ago #

    I have done that,but it didn't work.

  5. jeezyo
    Member
    Posted 2 years ago #

    take a look here so you can see how to properly load jquery.
    http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/

    and yes, youre going to need to replace $ with jQuery also.

  6. Triple P
    Member
    Posted 2 years ago #

    You will have to (register and) enqueue the script: http://codex.wordpress.org/Function_Reference/wp_enqueue_script. See also admin_enqueue_scripts

  7. pinagby
    Member
    Posted 2 years ago #

    The problem is that when i put thes codes :

    $(document).ready(function(){
    alert("ddd");
    });
    </script>

    in header.php, it can work ,but when i put those codes in the file of my plugin, it can't work.

  8. pinagby
    Member
    Posted 2 years ago #

    Thanks to all of you,Good Luck!

Topic Closed

This topic has been closed to new replies.

About this Topic