jQuery does not work on WordPress editor
Your jQuery code is using the $ symbol without accounting for noConflict mode. More information: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers
Your jQuery code is using the $ symbol without accounting for noConflict mode. More information: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers
Download the script (or add it via npm > bower to your theme), wp_enqueue_script() it at the wp_enqueue_scripts hook and then simply add/enqueue another (your custom) script where you add the contents of the demo index.html file: ( function( $ ) { $( “img” ).photoResize( { bottomSpacing: 15 } ); } )( jQuery || {} … Read more
Yes, PHP can have JavaScript (and CSS and HTML) in it, but you must tell: “here ends PHP -> other language -> here starts PHP”, like so: <?php echo ‘<div id=”hide-me”>something</div>’; ?> <script> // some JS to hide the div </script> <?php echo ‘another thing’; On the other hand, your code will not work because … Read more
WordPress runs $.noConflict(); by default. You attempting to run it again manually likely throws a TypeError: Cannot call method ‘noConflict’ of undefined Make use of your browser’s JS console rather than jsbin…
use “jQuery” instead of “$”: jQuery(document).ready(function(){ jQuery(“#mydiv”).addClass(‘myclass’); //or some function here }); …as found in the codex page.
So this is what I did to make it work: <form id=”formid” name=”form” action=”https://wordpress.stackexchange.com/checkout” method=”get”> Text: <input type=”text” name=”text”><br> <a href=”https://wordpress.stackexchange.com/checkout” target=”_parent” onclick=”document.getElementById(‘formid’).submit();”>Finish</a> <input type=”hidden” name=”mess” value=Finish /> </form>
Hey use admin_enqueue_scripts. if you want to load a set of CSS and/or Javascript documents to all admin pages. You can do this from within your plugin or from your themes function file using admin_enqueue_scripts: function class_table_scripts() { wp_register_script( ‘JavaScript1’, plugins_url(‘js/wcs.css’), array() ); wp_enqueue_script(‘JavaScript1’); wp_register_script( ‘JavaScript1’, plugins_url(‘js/jquery.qtip-1.0.0-rc3.min.js’), array(‘jquery’) ); wp_enqueue_script(‘JavaScript1’); } add_action( ‘admin_enqueue_scripts’, ‘class_table_scripts’ );
Just use deps parameter to include jQuery, change your code to: function add_my_css_and_my_js_files() { wp_register_script( ‘validate’, plugins_url( ‘/validate.js’, __FILE__ ), array( ‘jquery’ ) ); wp_enqueue_script(‘validate’); } add_action( ‘wp_enqueue_scripts’, “add_my_css_and_my_js_files” );
You should use the WordPress AJAX-API for those purposes instead of custom scripts. Your problem is, that in your script all the WordPress API-Objects are not loaded. Here is an answer which describe the usage of the AJAX-API in a very similar case. There, a post is inserted to the database in the wpse_126886_ajax_handler() function. … Read more
I think the real answer here, is to have the plugin author load scripts properly using wp_enqueue_script(). Or, you could change the theme enqueue code to output jquery to the header by changing to this (not great for performance reasons, but relatively simple): wp_enqueue_script( ‘jquery’, get_template_directory_uri() . ‘/js/jquery/jquery.min.js’, array(), ‘1.0.0’, false ); Or, you could … Read more