我们将如何获得特定<ul>在jquery中
How will we get the id of a particular <ul> in jquery?
这是jquery函数,它使ul可拖动和特定区域可丢弃。//Jquery
$(function () {
// there's the gallery5 and the trash
var $gallery5 = $("#gallery5"),
$trash = $("#trash");
// let the gallery5 items be draggable
$("ul", $gallery5).draggable({
cancel: "a.ui-icon", // clicking an icon won't initiate dragging
revert: "invalid", // when not dropped, the item will revert back to its initial position
containment: "document",
helper: "clone",
cursor: "move",
});
// let the trash be droppable, accepting the gallery items
$trash.droppable({
accept: "#gallery > li",
accept: "#gallery2 > li",
activeClass: "ui-state-highlight",
drop: function (event, ui) {
alert("trash");
deleteImage(ui.draggable);
}
});
// let the gallery be droppable as well, accepting items from the trash
$gallery5.droppable({
accept: "#gallery li , #gallery2 li , #gallery4 li , #gallery3 li",
activeClass: "custom-state-active",
drop: function (event, ui) {
alert("gallery5");
recycleImage(ui.draggable);
}
});
// image deletion function
var recycle_icon = "<a href='link/to/recycle/script/when/we/have/js/off' title='Recycle this image' class='ui-icon ui-icon-refresh'>Recycle image</a>";
// image recycle function
var trash_icon = "<a href='link/to/trash/script/when/we/have/js/off' title='Delete this image' class='ui-icon ui-icon-trash'>Delete image</a>";
function recycleImage ($item) {
// alert("recycleImage");
$item.fadeOut(function () {
$item
.find("a.ui-icon-refresh")
.remove()
.end()
.css("width", "250px")
.find("img")
.css("height", "50px")
.end()
.fadeIn()
.appendTo($gallery5);
});
}
// image preview function, demonstrating the ui.dialog used as a modal window
});
这是在循环中调用的,数据来自数据库。//身体
<ul id=coming from database>
<li>
description
id
</li>
</ul>
输出中有多个uls。我想检查我正在拖动的特定ul的id。Thanx。
$('ul').each(function(){
var ulID = $(this).attr('id');
});
这将从每个ul获得ID,然后你可以用它做你需要的事情。
你试过这个吗:
var ids = '';
$('ul').each(function(){
ids += $(this).attr('id');
});
试试这个:
$('ul').each(function()
{
var ids= $(this).attr('id'); // This is your rel value
});
相关文章:
- 将所选类别循环到ul>李用加载更多按钮
- 使用下拉列表筛选列表(ul>li)
- 如何附加<ul><李>元素位于某个特定条件的父元素列表之间
- 在验证器中添加自定义规则以检查<ul>具有元素
- 将OnClick函数设置为<ul>,最后一个ul是擦除第一个ul-s
- 排序<李><Ul>根据<span>内部<李>
- CSS/.JS问题,<ul><李>在Megamenu中
- 如何附加<李>至<ul>使用可拖动和可丢弃
- 如何将逗号分隔的列表转换为<ul>列表
- jQuery复选框(在ul>li下)检查事件
- Nav<ul>mouseout吗?如何修复
- Jquery将css类添加到父级<ul>元素
- 如何将Array转换为<ul><李>以字母为标题的字母列表
- jQuery对嵌套在<李>并且<a>元素,同时离开父<ul>打开
- jQuery访问列表视图->ul->李->span->img
- 可折叠<UL><李>不起作用
- JavaScript将缩进文本转换为HTML列表重复顶层<李>'s为<ul>'s
- 淘汰赛-给一个<李>foreach中的元素<ul>其中<李>元素
- 转换UL->li inot为同位素过滤菜单选择的列表
- 我们将如何获得特定<ul>在jquery中