Skip to content

Instantly share code, notes, and snippets.

@kumarldh
Created March 16, 2014 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumarldh/9584782 to your computer and use it in GitHub Desktop.
Save kumarldh/9584782 to your computer and use it in GitHub Desktop.
When you cut down a head of Hydra, another two heads appear. A button is a head.
<!DOCTYPE html>
<html>
<head>
<title>Hydra - Delete one button & produce two more!</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body id="hydrabody">
<button class="hydrahead">Hydra Head</button>
</body>
<script src="http://yui.yahooapis.com/3.15.0/build/yui/yui-min.js"></script>
<script>
YUI().use('node', 'event',function (Y) {
var hydra = function(e){
Y.one(e.target).remove();
var twoheads = Y.Node.create('<button class="hydrahead">Hydra Head</button><button class="hydrahead">Hydra Head</button>');
Y.one('#hydrabody').insert(twoheads);
};
Y.one('#hydrabody').delegate('click', hydra, 'button');
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment