Skip to content

Instantly share code, notes, and snippets.

@omariosouto
Last active August 16, 2016 21:03
Show Gist options
  • Select an option

  • Save omariosouto/2c7eca7136fd463268f9b8fa36b1dc01 to your computer and use it in GitHub Desktop.

Select an option

Save omariosouto/2c7eca7136fd463268f9b8fa36b1dc01 to your computer and use it in GitHub Desktop.
down vote
accepted
You could do it as follows:
<div data-myattr="hello"></div>
function countUp(){
console.log('hello');
}
function executeFunctionFromData(){
var d = 'countUp' // Save `data-myattr` to d; (Obviously, this is just a hardcoded value as an example)
window[d](); // Execute the function.
}
<div data-in="countUp" data-type="function" data-number="300" data-delay="1000" data-duration="2s">
</div>
<script>
function countUp(number, delay, duration) {
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment