开发者

Jquery - drag and drop into particular area

开发者 https://www.devze.com 2023-03-20 02:23 出处:网络
Here my Jquery: $(\".list\").draggable({helper: \'clone\', cursor: \'hand\'}); $(\".drop1\").droppable({

Here my Jquery:

    $(".list").draggable({helper: 'clone', cursor: 'hand'});
    $(".drop1").droppable({
        accept: '.list',
        hoverClass: 'dropareahover',
        drop: function(ev, ui){
         var targetId = $(this).attr("id");
         var allTargets = $("#" + targetId, ".tble");
         $("#" + targetId).each(function() {         
            //here i have to write the conditions.                      
            });
        }
 });      

i need to 开发者_如何学Cplace the content into particular area. if i place the content other area. it will not accept.


Could this be what you are looking for? (the revert option for jquery draggable)

$(".list" ).draggable({ helper: 'clone', cursor: 'hand', revert: 'invalid'});

From: http://jqueryui.com/demos/draggable/

If revert set to true, the element will return to its start position when dragging stops. Possible string values: 'valid', 'invalid'. If set to invalid, revert will only occur if the draggable has not been dropped on a droppable. For valid, it's the other way around.

Code examples

Initialize a draggable with the revert option specified.

$(".selector" ).draggable({ revert: true });

0

精彩评论

暂无评论...
验证码 换一张
取 消