Jquery

1. Jquery not working

Sometime we write jquery code like this

import $ from "jquery";

const YourFunction = () => {
	const init = () => {
		login();
	};

	const login = () => {
		// your code
	};

	init();
};

(function ($) {
	YourFunction();
})(jQuery);

An the issue come from jquery that we use conflict witrh jquery default from wordpress. The alternative solution is change your code like this

(function ($) {
   const YourFunction = () => {
      const init = () => {
         login();
      };

      const login = () => {
         // your code
      };

      init();
   };

   YourFunction();
})(jQuery);

Last updated