locked
Show/ Hide multiple text boxes on a button click RRS feed

  • Question

  • User-1320276304 posted

    how to Show/ Hide multiple text boxes on a button click?

    Thursday, July 23, 2020 5:46 AM

Answers

  • User1686398519 posted

    Hi Isuru_anu27,

    You can use toggle in jquery. Here’s the example.You can refer to it.

    <button id="buttontest" type="button" class="btn-primary">show/hide</button>
    <div id="test">
        @Html.TextBox("abc")
        @Html.TextBox("efg")
    </div>
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.0.js"></script>
    <script>
        $(document).ready(function () {
            $("#buttontest").click(function () {
                $("#test").toggle();
            });
        });
    </script>

    Here is the result.

    Best regards,

    Yihui Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 23, 2020 8:52 AM

All replies

  • User1686398519 posted

    Hi Isuru_anu27,

    You can use toggle in jquery. Here’s the example.You can refer to it.

    <button id="buttontest" type="button" class="btn-primary">show/hide</button>
    <div id="test">
        @Html.TextBox("abc")
        @Html.TextBox("efg")
    </div>
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.0.js"></script>
    <script>
        $(document).ready(function () {
            $("#buttontest").click(function () {
                $("#test").toggle();
            });
        });
    </script>

    Here is the result.

    Best regards,

    Yihui Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 23, 2020 8:52 AM
  • User-1320276304 posted

    Thank you so much!

    Friday, July 24, 2020 3:39 AM
  • User-1320276304 posted

    It works fine but I want to Hide all text boxes on start and need to show after clicking the button.

    Can you help me with this?

    Thursday, July 30, 2020 2:44 AM