I wrote the following HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="j1.js" **defer**></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Elderflower</title>
</head>
<body>
<h1 class="target">Hii</h1>
<h1>Unmodified</h1>
<h1 class="target">Hii</h1>
</body>
</html>
and here's the javascript:
let el = document.querySelectorAll(".target");
for(let i=0;i<el.length;i++)
{
el[i].innerText = "Modified by JS";
}
Why does my javascript not make modifications until I don't put the word defer in line 4 in html??