Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 16
    @gemma The other solution did not work for me but this one did. Thanks for being late. Commented Apr 25, 2012 at 17:56
  • 3
    @dlackey it's the same for me, the other solution did not work on my firefox 12, but this one did. Thanks Commented May 24, 2012 at 12:43
  • 4
    The top answer doesn't seem to work for getting the ID of an element in an embedded SVG. $(this).attr("id"); does. Commented Jun 26, 2014 at 9:21
  • 3
    Keep in mind that if your click event is on an element with children, e.target will give you the exact element that caused the event to be fired even if it was a child, whereas this will give you the element that the event is attached to. Commented Jul 12, 2016 at 21:37