在onClick上,单击DIV以使其展开

时间:2013-10-14 14:05:52

标签: onclick submit

我希望如果您点击文本搜索按钮出现,我会尝试使用此代码:

<a class="gn-icon gn-icon-search" style="width:200%;" onClick="CLICK ON THE BUTTON DIV">Search with style</a>
                            <ul id="sb-search" class="sb-search" style="margin-right:30px;">
                            <span class="sb-icon-search"></span>
                    <form>
                        <input class="sb-search-input" placeholder="Please enter search terms" type="text" value="" name="search" id="search">
                        <input class="sb-search-submit" type="submit" value="" id="search-submit">

                    </form>
                </div>

有人知道如何解决这个问题吗?也许用jQuery?非常感谢你!

1 个答案:

答案 0 :(得分:0)

使用JQuery,您可以在链接点击时显示按钮。

HTML:

<a class="gn-icon gn-icon-search" id="search-text" style="width:200%;">Search with style</a>
<ul id="sb-search" class="sb-search" style="margin-right:30px;">
    <span class="sb-icon-search"></span>
    <form id="search-form">
        <input class="sb-search-input" placeholder="Please enter search terms" type="text" value="" name="search" id="search">
        <input class="sb-search-submit" type="submit" value="" id="search-submit">
    </form>
</ul>

JQuery:

$(document).ready(function() {
    $('#search-form').hide();
});

$('#search-text').click(function() {
    $('#search-form').show();
});