Skip to content

Instantly share code, notes, and snippets.

@lilrogalski
Created January 10, 2015 18:46
Show Gist options
  • Save lilrogalski/67adea078940fa49bd4d to your computer and use it in GitHub Desktop.
Save lilrogalski/67adea078940fa49bd4d to your computer and use it in GitHub Desktop.
$.fn.extend renameAttr: (name, newName, removeData) ->
val = undefined
@each ->
val = $.attr(this, name)
$.attr this, newName, val
$.removeAttr this, name
# remove original data
if removeData isnt false
$.removeData this, name.replace("data-", "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment