Skip to content

Instantly share code, notes, and snippets.

@foxxtrot
Created July 27, 2009 21:36
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 foxxtrot/156751 to your computer and use it in GitHub Desktop.
Save foxxtrot/156751 to your computer and use it in GitHub Desktop.
<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