下拉文本框的按钮

时间:2015-12-02 01:22:41

标签: html css button click dropdown

我尝试使用CSS / HTML编写按钮,当您点击它时,它会下拉/显示一个文本框。

这是我想要实现的目标的形象:

what I'm trying to achieve

2 个答案:

答案 0 :(得分:0)

试试这个:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">    </script>
<script> 
$(document).ready(function(){
$("#flip").click(function(){
    $("#panel").slideToggle("slow");
});
});
</script>

<style> 
#panel, #flip {
padding: 5px;
text-align: center;
background-color: #e5eecc;
border: solid 1px #c3c3c3;
}

#panel {
padding: 50px;
display: none;
}
</style>
</head>
<body>

<div id="flip">Click to slide down panel</div>
<div id="panel">Hello world!</div>

</body>
</html>

答案 1 :(得分:0)

试试这个:

<!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">    </script>
    <script>
        $(document).ready(function(){
            $("#pcontainer").toggle();
            $(".btn2").click(function(){
            $("#pcontainer").slideToggle();
        });
    });
    </script>
    <style>
        background: [your_background_color];
    </style>
    </head>
    <body>
        <div id="pcontainer">
        <p>Your text.</p>
        </div>
        <button class="btn2">Slide down</button>

    </body>
    </html>