I have a js file with a function inside called showProduct.
In my HTML document I have a submit button which has this javascript:
onclick="showProduct(document.getElementById('suggest1').value);"
This gets the value of an input field with the id of suggest1 and is then passed to the function showProduct. This works fine! But as soon as I add this before & after my jquery:
(function($) { .... })(window.jQuery);
I get: Uncaught ReferenceError: showProduct is not defined at HTMLButtonElement.onclick
Any ideas on how I can get this to work? I need to put all the jQuery in this function to get it work with WordPress.
Thanks
$inside the function, the simplest fix isvar $ = jQuery;as the first line inside the function.