In order to brush up on the jQuery I half-learned, I was going through the Digital Web crash course today and trying to accomplish the task without reading the code sections, but while still mimicking their methods. The part I got stuck on is here:
$('#tabs a').click(function () {
// Assign value of the link target
var thisTarget = $(this).attr('href');
// Show target tbody and hide others
$(thisTarget).addClass('selected');
this.blur();
return false;
So what’s happening is that a user clicks a tab with the href of #row_5, and the tbody with the id=”row_5″ gets the selected class. For the longest time, I was trying to figure out how getting the href attribute of the link would automatically pull the target tbody correctly…was I missing something? Was an entire jQuery object getting kept as the thisTarget var? Was there some mysterious connection between the href and the tbody id?
Turns out I was looking at it backwards, while the simplest answer eluded me. I was assuming the # in the hrefs was just for canceling the click (which, I know, wouldn’t be necessary), but it was there for a trickier purpose: Storing “#row_5″ as the variable meant outputting it into $( ) creates an instant id selector.
Like I said, incredibly obvious, but I’m still getting into a lot of this and when things go wrong, I start to assume I’m missing some massive aspect I’ve yet to learn. STILL I FORGE ON.


Forge one doogles… forge on!