-2

It shows that $ is not a function

here is my function.php code

wp_enqueue_script( 'mail-scripts', get_template_directory_uri() . '/js/mail-script.js', array ( 'jquery' ), 1.1, true);


$(document).ready(function() {
        var form = $('#myForm');

2 Answers2

0

Wrap your jQuery code in this:

(function($){

    // jQuery code is in here

})(jQuery);
Ali_k
  • 1,642
  • 1
  • 11
  • 20
  • thank you but its not helping bro please suggest another way . see this link it is showing this again https://i.stack.imgur.com/jDW8a.png – Kshitiz Dhungel Jun 24 '19 at 12:19
  • Make sure you wrap that code inside the code I gave you, so before the error line add this `(function($){` and go to the end of ready function and add this after `})(jQuery);` – Ali_k Jun 24 '19 at 16:38
  • make these changes in the mail-script.js file not in the functions file, this is wrong – Ali_k Jun 24 '19 at 16:39
0

Try replacing "$" with "jQuery" in you js file and test.

Sujeesh S
  • 16
  • 1