/ Published in: jQuery
The purpose of this hook method is to help provide a separation of concerns between CSS and JavaScript.
Typically class names are used to attach JavaScript to HTML elements. Using a separate data-hook attribute helps to protect the scripting from CSS changes.
With the following example toggle button for a menu, we can hook on to the data-hook attribute.
Toggle Nav Menu
<ul>
<li><a href="/">West Philadelphia</a></li>
<li><a href="/cab">Cab Whistling</a></li>
<li><a href="/throne">Throne Sitting</a></li>
</ul>
Typically class names are used to attach JavaScript to HTML elements. Using a separate data-hook attribute helps to protect the scripting from CSS changes.
With the following example toggle button for a menu, we can hook on to the data-hook attribute.
Toggle Nav Menu
<ul>
<li><a href="/">West Philadelphia</a></li>
<li><a href="/cab">Cab Whistling</a></li>
<li><a href="/throne">Throne Sitting</a></li>
</ul>
URL: http://www.sitepoint.com/effective-event-binding-jquery/