Your selector is incorrect, prefix with .
, if you are using Class Selector (“.class”)
$('.class-to-div1')
instead of
$('class-to-div1')
You have same issue with $('class-to-div')
i think that addClass() is not the function, Definitely addClass() is a function
EDIT
Also you need to modify you .each(), callback function provide you index as you where passing counter
basically it was index
Change it to, remove counter parameter from .each()
$('.class-to-div1').each(function() {
$(this).addClass('sortable-div-' + counter);
});