Jörn Zaefferer schrieb:
> Klaus Hartl schrieb:
>> Kurt Mackey schrieb:
>>
>>> Is there a “jQuery” way of getting an event’s click target? I tend to
>>> use those elements quite a bit, but getting them is a pain. J
>>>
>> Hi Kurt,
>>
>> jQuery provides no functionality to retrieve the target. Here's my way
>> to do that:
>>
>>
>> $( ... ).click(function(e) {
>> var ev = e || event;
>> var target = ev.target || ev.srcElement;
>> $(target).css('border', '1px solid red');
>> });
>>
>> Maybe that should be abstracted by jQuery...
>>
> The first line is not necessary, afaik that is already normalized by
> jQuery. I'm not sure about the second one...
Yes you are right:
handle: function(event) {
...
event = event || jQuery.event.fix( window.event );
...
}
The target can easily be added to jQuery.event.fix:
fix: function(event) {
if ( event ) {
event.preventDefault = function() {
this.returnValue = false;
};
event.stopPropagation = function() {
this.cancelBubble = true;
};
event.target = event.srcElement;
}
return event;
}
Shall I add that?
-- Klaus
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/