How can I activate a horizontal tab?
window.location.hash returns the part of the URL after the #, including the #.
Passing to $() a string like, for example, "#tab1" selects any element that uses "tab1" as ID. (Differently, ".tab" selects any elements that uses "tab" as CSS class.)

$(window.location.hash, this) select all the elements that has window.location.hash as CSS selector, using this as context; this is the element on which an handler is triggered.
$().closest() returns then the first ancestor element that matches the selector passed ad argument.