Skip to content

Instantly share code, notes, and snippets.

@Wryhder
Wryhder / data-action.js
Created September 1, 2018 03:14 — forked from qborreda/data-action.js
JavaScript event hooking with data-action
// Set up HTML hooks without id or extra classes
<button data-action="openLogin">Login</button>
<a href="javascript:;" data-action="openEditor">Link</a>
// Using [data-action=""] selectors instead of class selectors when binding events in JavaScript
var actions = {
openLogin: openLoginWindow,
openEditor: function() { ... }
//....
};