Integrate jQuery
-
Hi there, I’ve been trying for hours and simply can’t get this to work. My jquery works perfect on Codenpen but nothing on WordPress.
My code is:
add_action( 'wp_enqueue_script', function () { wp_enqueue_script( 'jquery' ); }); ?> <script> function runFunction(){ $.noConflict(); jQuery(document).ready(function(){ // Your code in here jQuery('#billing_test').on('change', function() { myFunc(); }) function myFunc() { // your function code var complex_name = jQuery('#billing_test').val(); var suburb = jQuery('#billing_suburb').val(); if (complex_name == 'mr') { alert('works'); jQuery('#billing_postcode').val('5000'); } } }) } </script> <?php add_action( 'wp_head', 'runFunction');
I’ve tried with both $ and jQuery, it runs perfect in CodePen using the same code with corresponding HTML but does nothing on WP.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Integrate jQuery’ is closed to new replies.