为什么按钮也隐藏自己。我希望它们保持可见

时间:2014-10-02 15:54:18

标签: javascript jquery html css

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
    <head>
        <script type="text/javascript"></script>
        <script src="jquery-1.11.1.js"></script>
        <style type="text/css">
            button.allbut{
            background: none;text-shadow: none;margin:0,0,0,0;padding:0,0;
            border-radius: 0px;color: blue;font-size: 100%;
            font-family: Georgia, serif; text-decoration: none;
            vertical-align: left;background: white;
            border: none;text-align: center;
            }
            .showTopicbox{
            padding:0%,0%,0%,0%;margin:0%;border:0.1px red;width:50%;height:auto;
            background-color:white;color:black;
            }
        </style>
        <title>puff4</title>
    </head>
    <body>
        <button class="allbut" id="usinglabels">Using labels</button>
        <div id="usinglabels" class="showTopicbox">Some
            nice Queen's english here
            ...The property returns or sets a value that specifies which item in a
            ListBox control is displayed in the topmost position, commonly used to
            scroll Some nice Queen's english here
            ...The property returns or sets a value that specifies which item in a
            ListBox control is displayed in the topmost position, commonly used to
            scroll
        </div>
        <button class="allbut" id="connecting">Connecting</button>
        <div id="connecting" class="showTopicbox">Some
            nice Queen's english here
            ...The property returns or sets a value that specifies which item in a
            ListBox control is displayed in the topmost position, commonly used to
            scroll Some nice Queen's english here
            ...The property returns or sets a value that specifies which item in a
            ListBox control is displayed in the topmost position, commonly used to
            scroll
        </div>
        <script type="text/javascript">
            $("#usinglabels").click(function () {$('#usinglabels').slideToggle(0);});
            $("#connecting").click(function () {$('#connecting').slideToggle(0);});
        </script>
    </body>
</html>

1 个答案:

答案 0 :(得分:1)

ID不应该重复。

<button class="allbut" id="usinglabels">Using labels</button> <-- id
<div id="usinglabels" class="showTopicbox">Some  <--same id
$('#usinglabels').slideToggle(0);  <--what am I supposed to select?

更改您要隐藏的部分的ID。