【问题标题】:Put a box outside the scrollable-menu在可滚动菜单外放一个框
【发布时间】:2016-02-17 02:14:46
【问题描述】:

我有一个带有选项的可滚动下拉菜单。我还有一个搜索框(例如“CAR”)。现在搜索框成为可滚动菜单的一部分,因此当您向下滚动时,搜索框就会消失。我需要将搜索框固定在可滚动菜单的顶部。所以基本上我必须将搜索框“移出”可滚动菜单部分。问题出在我的 javascript 代码中(我的 html 很好,这是肯定的)但我找不到它,是否有可能实现我的目标?

我的开机...[开机][1]

【问题讨论】:

    标签: javascript jquery html


    【解决方案1】:

    只需像这样更改您的 HTML:

    <div class="dropdown-menu brand">
                <div style="position: relative;">
                    <input class="Car" placeholder="Car" type="text">
                    <div class=" scrollable-menu" style="margin-bottom: 70px;">
                        <div class="checkbox">
                    <label><input value="" type="checkbox"> Alpha</label>
                </div>
    

    我将 &lt;input class="Car" placeholder="Car" type="text"&gt; 移到了您的可滚动菜单 div 上方,毕竟这是您的 HTML。

    您还应该像这样更改变量 targetinput:

    var targetinput = currentgroup.find('.Car > input[type="text"]');
    

    它现在应该正确选择您的文本框,这是因为您试图在类可滚动菜单中找到一个文本框,但是我们将文本框移到了它之外。

    【讨论】:

    • 对不起,它仍然不正确,不知何故,当我更改我的 html 时,搜索框的功能丢失了,所以它必须在某个地方的 javascript 中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-25
    • 1970-01-01
    • 1970-01-01
    • 2021-10-20
    相关资源
    最近更新 更多