I got a problem with reffering to my A-tag in javascript, this is my js-code:
'use strict';
document.addEventListener('DOMContentLoaded', init);
function init() {
document.querySelector('.info .order').addEventListener('click', addToCart);
}
function addToCart(e) {
e.preventDefault();
alert("test");
}
<article data-id="2"><h3></h3><figure><img src="#"><figcaption></figcaption></figure><div class="info"><a class="order">Order</a></div></article>
If I click on the A-tag, the alert won't show up? BTW - The code works in snippit but it doesn't in PHPStorm.
Thanks in advance.