I have several classes that need all need the same information in .droppable() added to them. The only difference is one of the attributes. Is there a way I could have this with an .each loop instead of typing them all out? Example:
$(".te").droppable({
drop: swapPlayer,
hoverClass: 'drop-hover',
accept: '.te'
});
$(".rb").droppable({
drop: swapPlayer,
hoverClass: 'drop-hover',
accept: '.rb'
});
And so on with a bunch of other classes. I tried doing something like this but couldn't get it to work. I feel like I'm close though.
var pos = {".qb", ".rb"};
jQuery.each( pos, function( i, val ) {
$(val).droppable({
drop: swapPlayer,
hoverClass: 'drop-hover',
accept: val
});
});
So here we go, use an array, not an invalid object: