(function($) {
console.log( "ready!" ); // this happens
var detailsButton = $('a.cool-button');
console.log(detailsButton.click);
// this prints out to console:
// function (a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}
detailsButton.click(function(e) {
alert('i happened'); // never happens
e.preventDefault();
});
})(jQuery);
I have spent over an hour trying to troubleshoot this. What am I missing?
1 Answer 1
When enqueuing a script, you should state your script’s dependencies. In your case, it’s jQuery.