Hidden property of a button in HTML

后端 未结 2 1442
遇见更好的自我
遇见更好的自我 2021-02-01 03:54

I am trying to show three buttons on one button click. Before a button click all three buttons are hidden. I set the hidden property and I am also calling a function on a button

相关标签:
2条回答
  • 2021-02-01 04:27

    It also works without jQuery if you do the following changes:

    1. Add type="button" to the edit button in order not to trigger submission of the form.

    2. Change the name of your function from change() to anything else.

    3. Don't use hidden="hidden", use CSS instead: style="display: none;".

    The following code works for me:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="STYLESHEET" type="text/css" href="dba_style/buttons.css" />
    <title>Untitled Document</title>
    </head>
    <script type="text/javascript">
    function do_change(){
    document.getElementById("save").style.display = "block";
    document.getElementById("change").style.display = "block";
    document.getElementById("cancel").style.display = "block";
    }
    </script>
    <body>
    <form name="form1" method="post" action="">
    <div class="buttons">
    
    <button type="button" class="regular" name="edit" id="edit" onclick="do_change(); return false;">
        <img src="dba_images/textfield_key.png" alt=""/>
        Edit
    </button>
    
    <button type="submit" class="positive" name="save" id="save" style="display:none;">
        <img src="dba_images/apply2.png" alt=""/>
        Save
    </button>
    
    <button class="regular" name="change" id="change" style="display:none;">
        <img src="dba_images/textfield_key.png" alt=""/>
        change
    </button>
    
        <button class="negative" name="cancel" id="cancel" style="display:none;">
            <img src="dba_images/cross.png" alt=""/>
            Cancel
        </button>
    </div>
    </form>
    </body>
    </html>
    
    0 讨论(0)
  • 2021-02-01 04:31
    <html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script>
    
    function showButtons () { $('#b1, #b2, #b3').show(); }
    
    </script>
    <style type="text/css">
    #b1, #b2, #b3 {
    display: none;
    }
    
    </style>
    </head>
    <body>
    
    <a href="#" onclick="showButtons();">Show me the money!</a>
    
    <input type="submit" id="b1" value="B1" />
    <input type="submit" id="b2" value="B2"/>
    <input type="submit" id="b3" value="B3" />
    
    </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题