Positioning a tooltip relative to various kinds of elements
Create an array which contains : 


the id of element
the offset x
the offset y 


then, loop on each element of this array and do a single if.

Something like that (not tested)

var items = [
    {name: '#te_classbuilder', x: -120, y: -0},
    {name: '#lesson-details-extend-button', x: 0, y: 120},
    {name: 'label', x: 100, y: -120}
];

for (var i = 0; i &lt; items.length; i++) {

  var item = items[i];

  if ($element.is(items[i].name) {
    tooltipXPos = xPos + item.x; 
    tooltipYPos = yPos + item.y;
  }
}


If you know the key, use a map and don't use a loop in the array, simply get the item of the map using the key.