Created
September 19, 2011 20:11
-
-
Save fedemp/1227467 to your computer and use it in GitHub Desktop.
Y.one, Y.all and $() return values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h1 {font: bold 1.25em sans-serif; margin: 0.75em 0} | |
| ul {list-style-type: disc; padding: 0 0 0 5%} | |
| body {line-height: 1.5} | |
| b {font-family: monospace; background: yellow} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script> | |
| <script src="http://yui.yahooapis.com/3.4.0/build/yui/yui-min.js"></script> | |
| <h1>What are the return values when Y.one and Y.all (from YUI3) and $() (from jQuery) can't find the specified node.</h1> | |
| <ul> | |
| <li id="y-one">When Y.one() can't find a matching node, it returns <b></b>.</li> | |
| <li id="y-all">When Y.all() can't find a matching node, it returns <b></b>.</li> | |
| <li id="jquery">When $() can't find a matching node, it returns <b></b>.</li> | |
| </ul> | |
| <p>Please note that YUI3 has its own toString method that gives more information on the returned value.</p> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.addEventListener("load", function () { | |
| YUI().use("node", function (Y) { | |
| Y.one("#y-one b").setContent(Y.one("foo") + ""); | |
| Y.one("#y-all b").setContent(Object.prototype.toString.call(Y.all("foo")) + " " + Y.all("foo") + ""); | |
| }); | |
| $("#jquery b").html($("foo") + ""); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment