jquery droppable accept

后端 未结 8 2151
轻奢々
轻奢々 2020-12-13 07:02

Can anyone tell me how I can write a function in accept condition and then how does it finds out that what to accept and what not to accept. For example, I want to accept

8条回答
  •  自闭症患者
    2020-12-13 07:28

    If you want the droppable to accept a selection of elements you can do something like this:

    $(".droppable").droppable({
        accept: function(d) { 
            if(d.hasClass("foo")||(d.attr("id")=="bar")){ 
                return true;
            }
        }
    });
    

    This droppable will accept elements with the class "foo" or an element with the id "bar"

提交回复
热议问题