make div invisible and visible on button click using jquery

Dinav Ahire

i have one button and on the click of that button, i have one div to show and hide. i have achieved it using jquery. but problem is when page loads, div is already shown. and i want that, if i click on button then only div should be visible.

this is my code:

script:

<script>
$(document).ready(function() {
    $('#btn').live('click', function(event) {

        $('#div1').toggle('show');

    });
});
</script>

html :

<input type="button" id="btn" class="btncss" value="filter" />
<div id="div1" runat="server"  style="height:300px;width:300px;background-color:#f3fbd6">
    <table>
        <tr>
            <td>
                <asp:TextBox ID="txt" runat="server" TextMode="MultiLine"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <asp:DropDownList ID="ddl" runat="server"></asp:DropDownList>
            </td>
        </tr>
    </table>
    <hr />
    <table>
        <tr>
            <td>
                <asp:Button ID="btncancel" runat="server" Text="cancel" />
            </td>
            <td>
                <asp:Button ID="btnFilter" runat="server" CssClass="btncss" Text="Filter" />
            </td>
        </tr>
    </table>
</div>
Rory McCrossan

Use CSS to hide it by default:

#div1 {
    display: none;
}

Note that jQuery's live() method is deprecated, and shouldn't be used. It was replaced by on(). Also, your #div1 element has the runat="server" attribribute set on it, which means ASP.Net will automatically generate an id attribute for that element at run time. You will need to retrieve that id using the ClientID method:

$(document).on('click', '#btn', function() {
    $('#<%= div1.ClientID %>').toggle();
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Jquery script - Make Div visible on button click

From Dev

Making div invisible and visible using toggle in jQuery

From Dev

make visible and invisible a div tag in bootstrap

From Dev

how to make div visible using jquery?

From Dev

How to make a div visible and hidden on selecting different radio button in mvc using jquery?

From Dev

TextView visible invisible using one button in Android

From Dev

Why Div is not visible on button click

From Dev

hidden and make visible a div with a button

From Dev

Hide/Show Div on button click using Jquery

From Dev

making visible and invisible a button

From Dev

Button visible and invisible

From Dev

make a textbox visible on a tr(row) click and print the same of the data on button click in a DIV

From Dev

make a textbox visible on a tr(row) click and print the same of the data on button click in a DIV

From Dev

Div not going invisible when the visible set to false on button clcik

From Dev

OpenERP How to make a button invisible on button click event

From Dev

How to make views visible per button click

From Dev

how make a picture box visible with a button click

From Dev

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

From Dev

How to make a button become invisible but still be able to click?

From Dev

How to make a button become invisible but still be able to click?

From Dev

how to make text to get invisible from the page after a button click

From Dev

Invisible/visible submit button in a table

From Dev

Click button after it is visible in Selenium using python

From Dev

Click Button which is not visible on IRCTC, using Selenium

From Dev

Adding div dynamically using button click in JavaScript / 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

Related Related

  1. 1

    Jquery script - Make Div visible on button click

  2. 2

    Making div invisible and visible using toggle in jQuery

  3. 3

    make visible and invisible a div tag in bootstrap

  4. 4

    how to make div visible using jquery?

  5. 5

    How to make a div visible and hidden on selecting different radio button in mvc using jquery?

  6. 6

    TextView visible invisible using one button in Android

  7. 7

    Why Div is not visible on button click

  8. 8

    hidden and make visible a div with a button

  9. 9

    Hide/Show Div on button click using Jquery

  10. 10

    making visible and invisible a button

  11. 11

    Button visible and invisible

  12. 12

    make a textbox visible on a tr(row) click and print the same of the data on button click in a DIV

  13. 13

    make a textbox visible on a tr(row) click and print the same of the data on button click in a DIV

  14. 14

    Div not going invisible when the visible set to false on button clcik

  15. 15

    OpenERP How to make a button invisible on button click event

  16. 16

    How to make views visible per button click

  17. 17

    how make a picture box visible with a button click

  18. 18

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

  19. 19

    How to make a button become invisible but still be able to click?

  20. 20

    How to make a button become invisible but still be able to click?

  21. 21

    how to make text to get invisible from the page after a button click

  22. 22

    Invisible/visible submit button in a table

  23. 23

    Click button after it is visible in Selenium using python

  24. 24

    Click Button which is not visible on IRCTC, using Selenium

  25. 25

    Adding div dynamically using button click in JavaScript / jQuery

  26. 26

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

  27. 27

    load page on button click in specific div area using Jquery

  28. 28

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

  29. 29

    Adding div dynamically using button click in JavaScript / jQuery

HotTag

Archive