Hide/Show Div on button click using Jquery

后端 未结 3 1752
余生分开走
余生分开走 2021-01-13 06:03

This is supposed to be my first Jquery code that I am writing. I have used this and many more examples to make the simplest jquery code to display Hello on Button Click(W3Sc

相关标签:
3条回答
  • 2021-01-13 06:37

    You Ca Check it here http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_hide_show

    <!DOCTYPE html>
      <html>
        <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
          <script>
              $(document).ready(function(){
              $("#hide").click(function(){
                $("p").hide();
              });
              $("#show").click(function(){
                $("p").show();
              });
             });
         </script>
        </head>
        <body>
    
           <p>If you click on the "Hide" button, I will disappear.</p>
    
           <button id="hide">Hide</button>
           <button id="show">Show</button>
    
        </body>
     </html>
    
    0 讨论(0)
  • 2021-01-13 06:39
    <div>
    <input type="button" id="btn" class="btn btn-default" value="click me">
    </div>
    
    <div id="Create" style="display:none">
    Hello
    </div>
    
    @section Scripts{
    @Scripts.Render("~/bundles/jqueryval")
    <script type="text/javascript">
    $(document).ready(function () {
        $("#btn").click(function () {
            $("#Create").toggle();
        });
    });
    </script>
    }
    
    0 讨论(0)
  • 2021-01-13 06:42
    $(document).ready(function () {
       $("#btn").click(function () {
         $("#btn").click(function () { $("#Create").show();
       });
    });
    
    0 讨论(0)
提交回复
热议问题