Another Easy jQuery Question-Collection of common programming errors

Your issue is just scoping. In your load() callback, this refers to the element you’re calling load() on, which happens to be $('#sandbox'), and thus: no href. Usually what I do is something like this:

  var self = this;
    // Notice the use of self here, as we declared above
    alert("From here " + $(self).attr('href') + " to here.");
  return false;

Doing this ensures that you can still get to the thing that you clicked from inside the load() callback.

Originally posted 2013-11-09 20:01:40.