Hide/Show Div on button click using Jquery

Vini

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(W3Schools worth mentioning). I am trying to show a div that contains the Hello in it on a button click.

<div>
<input type="button" id="btn" class="btn btn-default" value="click me">
</div>

<div id="Create" style="visibility:hidden">
Hello
</div>

@section Scripts{
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$(document).ready(function () {
    $(btn).click(function () {
        $(Create).show();

    });
});
</script>
}

I have tried writing the Script code many places like in the head, after the Scripts.Render, before it. I am not really sure where i should place the Jquery code.

I have this code appended to a MVC5 application. This code is written for learning purpose. I think the other code in the View is irrelevant for the working of the Jquery.

Maha Dev
<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>
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to append child div into a parent div using jquery on the click of a button

From Dev

Adding div dynamically using button click in JavaScript / jQuery

From Dev

make div invisible and visible on button click using jquery

From Dev

Remove a class and hide a div on click of button using jquery

From Dev

load page on button click in specific div area using Jquery

From Dev

Find Input type = button in a div and click twice using jquery

From Dev

Adding div dynamically using button click in JavaScript / jQuery

From Dev

copy table or div content on button click using jquery

From Dev

div show in jQuery on button click

From Dev

Programmatically click a button using jquery

From Dev

Programmatically click a button using jquery

From Dev

Click Gridview button using jQuery

From Dev

move an element from one div to another div with animate effect on button click using html and jquery

From Dev

Hide/Show a div on button click jquery FOUNDATION

From Dev

JQuery click() on a div button won't fire

From Dev

Show nonunique div class on button click jquery

From Dev

Show div after button click jquery

From Dev

jquery for loop is not working in dialog div button click

From Dev

jquery refresh div with button click asp .net

From Dev

Jquery script - Make Div visible on button click

From Dev

How to show a div relative to the position of a button on click of that button in jQuery

From Dev

Display a Modal on button click using Jquery

From Java

Click button copy to clipboard using jQuery

From Dev

How to clear effect of a click button using jquery

From Dev

Prevent second button click using jQuery

From Dev

Download image on button click using jQuery

From Dev

Open new tab on button click using JQUERY

From Dev

Delaying the Submit button click using Jquery

From Dev

Remove old data on button click using jquery

Related Related

  1. 1

    How to append child div into a parent div using jquery on the click of a button

  2. 2

    Adding div dynamically using button click in JavaScript / jQuery

  3. 3

    make div invisible and visible on button click using jquery

  4. 4

    Remove a class and hide a div on click of button using jquery

  5. 5

    load page on button click in specific div area using Jquery

  6. 6

    Find Input type = button in a div and click twice using jquery

  7. 7

    Adding div dynamically using button click in JavaScript / jQuery

  8. 8

    copy table or div content on button click using jquery

  9. 9

    div show in jQuery on button click

  10. 10

    Programmatically click a button using jquery

  11. 11

    Programmatically click a button using jquery

  12. 12

    Click Gridview button using jQuery

  13. 13

    move an element from one div to another div with animate effect on button click using html and jquery

  14. 14

    Hide/Show a div on button click jquery FOUNDATION

  15. 15

    JQuery click() on a div button won't fire

  16. 16

    Show nonunique div class on button click jquery

  17. 17

    Show div after button click jquery

  18. 18

    jquery for loop is not working in dialog div button click

  19. 19

    jquery refresh div with button click asp .net

  20. 20

    Jquery script - Make Div visible on button click

  21. 21

    How to show a div relative to the position of a button on click of that button in jQuery

  22. 22

    Display a Modal on button click using Jquery

  23. 23

    Click button copy to clipboard using jQuery

  24. 24

    How to clear effect of a click button using jquery

  25. 25

    Prevent second button click using jQuery

  26. 26

    Download image on button click using jQuery

  27. 27

    Open new tab on button click using JQUERY

  28. 28

    Delaying the Submit button click using Jquery

  29. 29

    Remove old data on button click using jquery

HotTag

Archive