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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -