开发者

how to get class/id from ui & event

开发者 https://www.devze.com 2023-04-02 20:32 出处:网络
How to get id & class name of any element from ui & event of any function. please see below for clear understandin开发者_Python百科g .

How to get id & class name of any element from ui & event of any function. please see below for clear understandin开发者_Python百科g .

<div class"drag-class" id="drag1"> </div>
 <div class"drag-class" id="drag2"> </div>
      <div class"drop-class" id="drop1"> </div>
      <div class"drop-class" id="drop2"> </div> 

JS:

   $(function(){
     $('.drag-class').draggable();

     $('.drop-class').droppable(function(){

              accept: '.drag-class'.
              drop: function(ui,event){
                /*here i want to know the id of drag-class & drop-class element element*/
                     }              
             });

       });'


From the docs -

In the callback, $(this) represents the droppable the draggable is dropped on. ui.draggable represents the draggable.


this.id and this.className should contain what you're looking for.

0

精彩评论

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