鼠标向下移动时,在div中滚动/拖动值

时间:2016-04-22 12:31:49

标签: javascript jquery css

我需要具有鼠标按下事件的可滚动div。例如,请参考此链接: https://sapui5.netweaver.ondemand.com/explored.html#/sample/sap.ui.comp.sample.valuehelpdialog.example1/preview

如果选定的值会溢出,那么我们可以滚动/拖动div,我们也可以看到其他值。

Before Scroll Div After Scroll Div

1 个答案:

答案 0 :(得分:0)

试试这个:



$(function () {
    $("#draggable").draggable();
});

#draggable {
    width: 150px;
    height: 150px;
    padding: 0.5em;
}
.scrollable{
    overflow-y:scroll;
    width: 150px;
    height: 150px;
}

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<div id="draggable" class="ui-widget-content">
    <div class="scrollable">
        <table id="t1">
            <tr class="item">
                <td>Item </td>
            </tr>
            <tr class="item">
                <td>Item </td>
            </tr>
            <tr class="item">
                <td>Item </td>
            </tr>
            <tr class="item">
                <td>Item </td>
            </tr>
            <tr class="item">
                <td>Item </td>
            </tr>
            <tr class="item">
                <td>Item </td>
            </tr>
            <tr class="item">
                <td>Item </td>
            </tr>
            <tr class="item">
                <td>Item </td>
            </tr>
            <tr class="item">
                <td>Item </td>

            </tr>
            <tr class="item">
                <td>Item </td>
            </tr>
        </table>
    </div>
</div>
&#13;
&#13;
&#13;