Instantly share code, notes, and snippets.

Embed
What would you like to do?
<html>
<head>
<title>Prepend Test</title>
</head>
<body>
<fieldset id="test_element">
<p>Text before legend</p>
<legend>Title of the Fieldset</legend>
<p>Text after legend.</p>
</fieldset>
<input type="button" id="btn" value="Apply Color" />
<input type="button" id="count" value="Count Paragraphs" />
<script src="http://yui.yahooapis.com/3.0.0b1/build/yui/yui-min.js" type="text/javascript"></script>
<script type="text/javascript">
YUI().use('stylesheet', 'node', function(Y) {
var sheet = Y.StyleSheet();
Y.on("click", function (e) {
var r = Math.floor(Math.random() * 256),
g = Math.floor(Math.random() * 256),
b = Math.floor(Math.random() * 256);
sheet.set('fieldset p', { color: 'rgb(' + r + ',' + g + ',' + b + ')' });
}, '#btn');
Y.on("click", function (e) {
alert(Y.get('fieldset').queryAll('p').size());
}, "#count");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment