0

I want to sleet a form using query slector but it says the value that it is picking up is null so its not finding my form

HTML code

<!DOCTYPE html>
<html>
<head>
    <title>This is the title</title>

    <!-- <link rel="stylesheet" href="CSS.css"> -->
    <script src="JS.js"></script>
    
</head>
<body>
    <h1 >Movie search</h1>
    <form id="searchForm">
        <input type="text" name="query">
        <button>Search</button>
    </form>



</body>

</html>

JS code

const form=document.querySelector('#searchForm');
console.log(form);
form.addEventListener("submit",function(e){

e.preventDefault();
console.log("Submitted...");

})
Dunmol
  • 31
  • 3

0 Answers0