最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Exclude item from handle on jQuery draggable - Stack Overflow

programmeradmin8浏览0评论

I have a draggable <div> with overflow set to auto to show a scrollbar when the content is too wide.

I want the entire content of the <div> to be draggable, so I have not added a handle. Now when I try to drag the scrollbar, the entire <div> is dragged instead of scrolling the content.

Is there a way of excluding an element from the handle of a draggable <div> in jQuery?

I need something like:

$("#element").draggable({
    handle: "not(#thisTable)"
})

Is there a way of doing this with selectors or something like that?

I have a draggable <div> with overflow set to auto to show a scrollbar when the content is too wide.

I want the entire content of the <div> to be draggable, so I have not added a handle. Now when I try to drag the scrollbar, the entire <div> is dragged instead of scrolling the content.

Is there a way of excluding an element from the handle of a draggable <div> in jQuery?

I need something like:

$("#element").draggable({
    handle: "not(#thisTable)"
})

Is there a way of doing this with selectors or something like that?

Share Improve this question edited May 8, 2018 at 21:09 Synesthetic Symphony 1472 silver badges7 bronze badges asked Sep 22, 2009 at 21:36 FortesFortes 93812 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 21

tnx for your answer, but i found what i think is a better solution....

there is another option for draggable called 'cancel' and it excludes the selected element from the handle of the draggable element...

$('#container').draggable('option', 'cancel', '#excludedElement');

hope this helps someone else...

Add a div inside your div, width & height 100%, no margin, no padding, and put your content there. Set its overflow to default and set it as the handle. That way, the scrollbar of the parent div will no longer be in the handle, thus not initiating the drag.

发布评论

评论列表(0)

  1. 暂无评论