I am trying to set the class of my element inside the data object of the same element, but it continues to return undefined.
$(this).data({
orgSize:{
width: $(this).width(),
height: $(this).height()
},
orgClass: function(){
cl = $(this).attr('class');
if(cl){
return ' ' + cl;
}else{
return ' somethingelse';
}
}
});
console.log($(this).attr('class'))
edit: the problem is within orgClass.
source
share