gpt4 book ai didi

javascript - 如何从 ui 和事件获取类/id

转载 作者:行者123 更新时间:2023-12-02 20:06:59 25 4
gpt4 key购买 nike

如何从任何函数的ui & event 获取任何元素的id 和类名。请参阅下文以获得清晰的理解。

<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*/
}
});

});'

最佳答案

来自docs -

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

关于javascript - 如何从 ui 和事件获取类/id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7330656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com