get class of grandparent jquery code example Example: how to get class name in jquery var className = $('#sidebar').attr('class');