我有这个标记
<ul id="hello" class="cat">
<ul id="a1" class="cat">
</ul>
<ul id="a2" class="cat">
</ul>
</ul>我做了这件事
$("ul.cat").droppable(
{
drop:function()
{
alert($(this).attr("id"));
}
});它总是写"hello“。只说“你好”。我怎样才能在childs上绑定droppable呢?
UPD:我希望在#hello的chidlren和#hello本身中删除元素。我想确定李是在哪里被丢下的。
发布于 2011-04-01 04:07:06
我已经找到了解决方案:#hello需要greedy:true
http://jqueryui.com/demos/droppable/#propagation
发布于 2011-04-01 03:02:56
试试这个:
$("ul.cat").each(function(){
$(this).droppable(
{
drop:function()
{
alert($(this).attr("id"));
}
});
})http://jsfiddle.net/maniator/HXjeQ/
发布于 2011-04-01 03:06:30
它会冒泡到顶部的UL,这是你不想丢弃的。试试这个:
$("#hello ul.cat").droppable(
{
drop:function()
{
alert($(this).attr("id"));
}
});here's a jsfiddle
https://stackoverflow.com/questions/5504888
复制相似问题