Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.