Home > Enterprise >  How do you hide an element using JQuery?
How do you hide an element using JQuery?

Time:10-29

So I'm making a website with jquery, however, the hide function doesn't work. My code is below:

$(document).ready(function () {
    $("#myDiv").hide
})

Does anyone know how to fix this?

CodePudding user response:

$(document).ready(function () {
    $("#mydiv").hide()
})

  $(".show").click(function(){
    $("#mydiv").show();
  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="mydiv">This is a div.</div>


<button class="show">Show</button>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  • Related