I have a plugin, from which within one of the files I am trying to include a JS file the proper way:
function inveroak_feed_search_enqueue() {
wp_enqueue_script('inveroak-feed-search', plugin_dir_url(__file__).'assets/js/search.js');
}
add_action('wp_enqueue_scripts', 'inveroak_feed_search_enqueue');
Further down the file I am referencing this function from an input field like this:
<input onkeyup="inveroak_feed_search(this)" />
However, whenever I press any key within the input, all I see is this in the console (and the JS file isn't being loaded also).
Uncaught ReferenceError: inveroak_feed_search is not defined at HTMLInputElement.onkeyup ((index):120)
Contents of search.js if it helps:
function inveroak_feed_search(element) {
(function($) {
var value = $(element).val();
$(".inveroak-feed-container").each(function() {
if ($(this).find(".op-name,.op-pin,.op-toolbox li").text().toLowerCase().search(value.toLowerCase()) > -1) {
$(this).show();
} else {
$(this).hide();
}
});
})(jQuery);
}
Can anyone help why this JS file isn't loading?