is there some equivalent of this
that can be derived from e.target
e.target
can be a child of this
.
you could do $(e.target).closest("a")
if you know what the selector is for the element that the click function is bound to.
But, what if you don't know the selector?
EDIT: for clarification:
I'm experiencing a
TypeError: Cannot call method 'createDocumentFragment' of undefined
error when I try to test a click function.
I have bound a click function to an element like so:
$(".original_list_trigger").click(Helpers.originalTextButtonClick);
and that is defined like this:
Helpers: {
originalTextButtonClick: function(e) {
var self = $(this);
console.log(self);
...
}...}
console.log(self) doesn't give an element, but the function itself, which isn't what I want. $(this) should be the element that has the function bound to the click event, right?
This is $(this):
so, it looks like $(this), is the object
Helpers
... :-\
UPDATE:
Basically, I'm dumb. the problem was being caused by this being invoked:
Helpers.originalTextButtonClick();
<- I wasn't passing anything as e, so.. of course e.anything wouldn't be defined.
Since I'm running tests through Jasmine, http://pivotal.github.io/jasmine/, I need to find a way to mock the event object, and this
. Or I could just trigger a click on the element (which I'll probably do, since that's easier)