Dynamic.js Extras demo

Dynamic.js is a small library that allows binding simple behaviours to DOM elements using data- attributes.

See the main Dynamic.js project docs here.

I copy the value when clicked based on a JSON config
I toggle a class when checked or unchecked based on a JSON config

I will be red if checked!

Add/remove class on click based on data attributes

I may be green

I set a class when changed based on a JSON config with an expression

I have the selected class applied!

Hiding and showing an element

I am visible!

Setting the text of an element

Initial text

Preventing the default action
Try to go to Google

Not going anywhere, as the default action was prevented

Toggling text
Copying HTML

My text

My HTML to copy
Setting/clearing focus