javascript - Loop through IDs with jQuery and make them droppable -
i've got container #itemgrid
, few children-divs. unique. code far:
$('#grid-top').droppable({ drop: drophandler, accept: ".top" }); $('#grid-assc').droppable({ drop: drophandler, accept: ".assc" });
as may see, accepting class in id of element. have more divs want make droppable, work. how can loop through these elements?
$("#itemgrid div[id^=grid-]").each(function() { var accept = $(this).attr("id").split("-")[1]; $(this).droppable({ drop: drophandler, accept: "." + accept }); });
Comments
Post a Comment