如何在具有相同类名且包含在主容器div中的div集合中选择div [英] how to select a div among sets of divs with thesame class name and contained in a main container div

查看:72
本文介绍了如何在具有相同类名且包含在主容器div中的div集合中选择div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是jquery新手.我想使用jquery中的拖放事件制作一个应用程序,但我无法在一组div中选择一个div,且其名称与主div中的名称相同.请问有人可以帮助我吗? 请注意,这些div集是动态生成的,可以从数据库中获取数据

hi to every one i am new in jquery. i want to make an app using the drag and drop events in jquery.but i am NOT able to select a div among a set of divs with thesame name contained in a main div.please can anybody help me ? note these set of divs are generated dynamically ,getting the data from the database

推荐答案

确切地说出您的需求真的很困难.

It is just really tough to tell exactly what you need.

听起来您的javascript中有动态生成的元素,而使这些元素可拖动却遇到了麻烦.

I sounds like you have elements that are generated dynamically in your javascript, and you are having trouble making those draggable.

我认为这意味着您已经成功使页面上的其他元素(可动态添加)变为可拖动状态.

I assume this means that you have successfully made other elements on the page draggable that were not added dynamically.

如果是这种情况,则在将新元素添加到页面之前,只需在添加新元素之前对其进行相同的draggable()调用即可.

IF this is the case, before you add your new element to the page, just do the same draggable() call on it before you add it.

   // Create new element
var $newElement = $("<div class='suggestion'>I'm a suggestion</div>");

   // Make it draggable
$newElement.draggable();

   // Append it to your container
$newElement.appendTo('.suggestions');

如果这不是您的意思,请在您的问题中非常清楚和详细.还请添加一个代码示例,该示例经常解释很多. :o)

If this is not what you mean, then please be very clear and detailed in your question. Please also add a code example, which often explains much. :o)

这篇关于如何在具有相同类名且包含在主容器div中的div集合中选择div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆