This is driving me crazy. I have a HTML page with a form element as shown below:
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="formHandler.js"></script>
<script src="app.js"></script>
</head>
<body>
<form data-coffee-order="form">
<input type="submit" />
</form>
</body>
In my app.js I try to access the form element using the querySelector as shown below:
var FORM_SELECTOR = '[data-coffee-order="form"]'
var form = document.querySelector(FORM_SELECTOR)
console.log(form) // this is null why?
For some reason form is always null. Why is that?