1

sorry for this question but I can't seem to figure it out. I am trying to hide the "#postcodeConf" element on page load but it just doesn't do it! I put the code in JSfiddle and it works as expected!

What am I doing wrong?!

<html>
<head>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<script>
$("#postcodeConf").hide();
</script>

</head>
<body>
        <input type="text" id="postcodeEntry">
        <button onclick="myFunction()">Search</button>
        <p id="postcodeConf">Postcode Ok</p>
</body>
</html>
Denton
  • 17
  • 3

1 Answers1

1
    <input type="text" id="postcodeEntry">
     <button onclick="myFunction()">Search</button>
     <p id="postcodeConf">Postcode Ok</p>  

    <script>
     $("#postcodeConf").hide();
    </script>

Add in the following order as dom element can be captured only after its rendered.

Arun Mohan
  • 1,207
  • 1
  • 5
  • 11