• Resolved agentoojoe

    (@agentoojoe)


    Hello,
    I have been going crazy trying to figure out why my jQuery code is not working. I am writing a plugin and I want to use jQuery effects on the admin page. Here is what I have:

    <?php  
    
    /*
    Plugin Name: jquerytest
    Plugin URI:
    Description: Meanwhile Media - jquerytest
    Version: 1.0
    Author: Me
    Author URI:
    License: GPL2
    */
    
    add_action('admin_menu', 'jquerytest');
    wp_enqueue_script('jquery');
    
    function jquerytest() {
    	add_menu_page('jquerytest', 'jquerytest', 'read', 'jquerytest', 'jquerytest_contents');
    }
    
    function jquerytest_contents() { ?>
    
        <input type="submit" name="togglepayout" value="Toggle" id="togglepayout" />
    	<div name="payout" id="payout" style="margin: 5px 0 0 10px;">
        Test Text Test Text etc. etc.
        </div> 
    
    	<script language="javascript">
    
    		jquery(document).ready(function() {
    			jquery('payout').hide();
    
    			jquery('#togglepayout').click( function() {
        			jquery('payout').toggle();
       			});
    
    		});
    
    	</script> 
    
    <?php } ?>

    Can anyone help me?
    Thanks!

The topic ‘How to include jQuery when writing a Plugin admin page’ is closed to new replies.