I am testing jQuery in my wordpress plugin. Two files 1. main_plugin.php 2. js_plugin.js (Both in the same directory HelloWorld).
CODE:
PHP FILE:
<?php
/*
Plugin Name: jQuery Test Plugin
Plugin URI: http://www.rabwahnetwork.net
Description: This plugin is a test
Author: Rana Faiz Ahmed
Author URI: http://www.rabwahnetwork.net
*/
function load_my_script()
{
wp_enqueue_script( 'script-name', WP_PLUGIN_URL . 'HelloWorld/js_plugin.js', array("jquery"), false, true );
}
add_action( 'wp_enqueue_scripts', 'load_my_script' );
JS file:
jQuery('.entry-header').click(function(e) {
e.preventDefault();
jQuery(this).remove();
});