Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Snaphaan on "Running jquery inside plugin admin page"

$
0
0

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 all articles
Browse latest Browse all 8245

Trending Articles