javascript - Call a js file from a plugin directory -


i creating wp plugin. in plugin folder have js folder contains small js file named call.js. plugin have functions.php file.

now, getting issues (like js content being visible on front end) outing js.

in plugin functions.php have following

function basic_script() {     wp_register_script( 'custom-script', plugins_url( '/js/call.js', __file__ ));     wp_enqueue_script( 'custom-script' ); } add_action( 'wp_enqueue_scripts', 'basic_script'); 

the plugin file looks correct

require plugin_dir_path( __file__ ) . 'js/call.js'; 

i added following js in js file

(function($) { $(document).ready(function() { var newval = $('#div2'); $('#div1').html( newval ); }); })(jquery) 

i understand making error somewhere unable find this.

thanks in advance.

try this

$(document).ready(function() { var newval = $('#div2'); $('#div1').html( newval ); }); 

remove function code


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -