Skip to content

Instantly share code, notes, and snippets.

@r37r0m0d3l
Created November 15, 2012 11:08
Show Gist options
  • Save r37r0m0d3l/4078044 to your computer and use it in GitHub Desktop.
Save r37r0m0d3l/4078044 to your computer and use it in GitHub Desktop.
javascript get dataset from event
// as property
event.currentTarget.dataset.id
// as array element
event.currentTarget.dataset['id']
// jquery method
$(event.currentTarget).data('id')
@thirdj
Copy link

thirdj commented Jul 12, 2016

thx

@Thalvik
Copy link

Thalvik commented Aug 9, 2016

Thank you, needed this when returning content from AJAX request

@tng-sy
Copy link

tng-sy commented May 9, 2018

ty

@esteban22x
Copy link

Thank you!!!!
That's the nice thing about vanilla JS, Still working like a charm!

@andreescocard
Copy link

thxxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment