locked
How to change css display none or block property using Jquery? RRS feed

  • Question

  • User-1682137340 posted

    hi can any one help me please

    here is link of my problem ,

    https://jsfiddle.net/5bk090gs/1/

    when i click on hyper link it can't changing display css property to  block property of another div.

    and hyper  link must hide.

    Sunday, October 25, 2015 1:03 AM

Answers

  • User632428103 posted

    Hello,

    if i copy you code to my visual studio environnment all work :

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            .showhide{display:none;}
        </style>
        <script src="../../Scripts/jquery-1.7.1.js"></script>
        <script type="text/javascript">
    
            $(document).ready(function () {
                $('#go').click(function () {
                    $('#show').css('display', 'block');
                });
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <a id="go" href="#" >Previous</a>
        <div class="showhide" id="show">
            hi how are you
        </div>
        </form>
    </body>
    </html>

    i don't know how you jsfiddle not work ..i've look but i haven't see an error ..

    put an alert in your code perhpas ..

    hope this help

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 25, 2015 12:20 PM
  • User61956409 posted

    Hi gaddamraju4u,

    As jimmy69 said, the code seems ok. Please make sure whether you add reference to jQuery file like this.

    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>

    Besides, here is the sample that is working fine on my side.

    <a id="go" href="#">Previous</a>
    
    <div class="showhide" id="show">
        hi how are you
    </div>
    
    <style>
        .showhide {
            display: none;
        }
    </style>
    
    <script>
        $(function () {
            $('#go').click(function () {
                $('#show').css("display", "block");
            });
        })
    </script>
    

    Best Regards,

    Fei Han




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 26, 2015 3:19 AM

All replies

  • User632428103 posted

    Hello,

    if i copy you code to my visual studio environnment all work :

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            .showhide{display:none;}
        </style>
        <script src="../../Scripts/jquery-1.7.1.js"></script>
        <script type="text/javascript">
    
            $(document).ready(function () {
                $('#go').click(function () {
                    $('#show').css('display', 'block');
                });
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <a id="go" href="#" >Previous</a>
        <div class="showhide" id="show">
            hi how are you
        </div>
        </form>
    </body>
    </html>

    i don't know how you jsfiddle not work ..i've look but i haven't see an error ..

    put an alert in your code perhpas ..

    hope this help

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 25, 2015 12:20 PM
  • User61956409 posted

    Hi gaddamraju4u,

    As jimmy69 said, the code seems ok. Please make sure whether you add reference to jQuery file like this.

    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>

    Besides, here is the sample that is working fine on my side.

    <a id="go" href="#">Previous</a>
    
    <div class="showhide" id="show">
        hi how are you
    </div>
    
    <style>
        .showhide {
            display: none;
        }
    </style>
    
    <script>
        $(function () {
            $('#go').click(function () {
                $('#show').css("display", "block");
            });
        })
    </script>
    

    Best Regards,

    Fei Han




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 26, 2015 3:19 AM