So I'm a beginner in JavaScript.
I have this simple HTML file where I tried to test jQuery with $("h1").hide() and my problem is that the jQuery code works in the HTML but when I try to put this code in an external JavaScript file testjs.js and insert it via script tag to the head, it doesn't works anymore. Just to be clear, the external JavaScript file is recognized, for example when I put document.write("third test") in the external JS file it will show "third test".
Hope I've been clear
<!doctype html>
<html>
<head>
<title>Test</title>
<meta charset="utf-8"/>
<script src="jquery-3.3.1.min.js"></script>
<script src="js/testjs.js"></script>
</head>
<body>
<h1>first test</h1>
<p>second test</p>
<!-- this works only here but not in external js file
<script>
$("h1").hide();
</script>
-->
</body>
</html>
testjs.jsfile in that same order?<script>tags in other file. And add script file at bottom</body>or wrap the code in$(function() { $("h1").hide(); });