Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

jquery - how to select a div among sets of divs with thesame class name and contained in a main container 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.

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');

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...