I want to trigger the js function when the class subcat-tab is clicked, but it seems not to be working. I don't have any error messages but nothing is happening.
I'm under a phtml
file from Magento 2.
<a href="#subcat_<?= $subcatId ?>" class="subcat-tab" title="<?= $subcat['label'] ?>" data-categoryid="<?= $subcatId ?>">
<script type="text/javascript">
define([
'jquery'
], function ($) {
console.log("ok");
$('.subcat-tab').click(function (e) {
console.log(e);
}
});
</script>
Using require
instead of define
fix it somehow but don't really know why.