• Resolved Snaphaan

    (@snaphaan)


    This is a simple piece of jqeury I have picked up from JSFiddle:

    $('.sample').on('click', function () {
    
        console.log(this);
        var choice = $(this);
    
        if (choice.is(":checked")) {
            $('#choices').append(choice.val() + " is checked!");
        }
    });

    Here is the html:

    <div id="top-menu">
        <input type="checkbox" class="sample" value="a">A</input>
        <input type="checkbox" class="sample" value="b">B</input>
        <input type="checkbox" class="sample" value="c">C</input>
    </div>
    <label>Choices</label>
    <div id="choices"></div>

    And this is how I enqued jquery in my functions.php:

    function load_jquery() {
        wp_enqueue_script( 'jquery' );
    }
    add_action( 'wp_enqueue_script', 'load_jquery' );

    But nothing works! I’v tried a number of other simple scripts for instance:

    jQuery(document).ready(function(){
    
        alert("Hello");
    });

    .. and still nothing.

    Any help would be greatly appreciated.

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    To enqueue scripts for admin pages, you must hook ‘admin_enqueue_scripts’, not ‘wp_enqueue_scripts’, that is only for front end pages.

    Thread Starter Snaphaan

    (@snaphaan)

    Thanks a million for your response!!!

    I’ve kinda found a work around enqueuing the script but it is… was not ideal.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Running jquery inside plugin admin page’ is closed to new replies.