$(document).ready(function(){
// Code
});
Y.on("domready", function(e){
// Code
});
<div class="demo">this is a div</div> <div class="foo">this is a div</div> <div class="foo">this is a div</div>
$(".demo");
$("div.foo:first")
$('div:even')
$(':radio')
$('div:gt(n)');
Y.one(".demo");
Y.one("div.foo")
Y.all('div').even()
Y.all('input[type=radio]')
Y.all(Y.all('div')._nodes.slice(n + 1))
<div class="demo">this is a div</div>
$(".demo").append("
hi, I'm Adam.
");
$("<div/>");
$("#id3").remove();
.html("foo")
$('div').concat($('p'))
Y.one(".demo").append("
hi, I'm Adam.
");
Y.Node.create("<div/>");
Y.one("#id3").remove();
.set("innerHTML", "foo")
Y.all(
Y.all('div')._nodes.concat(
Y.all('p')._nodes
)
)
<div class="demo">this is a div</div>
$(".demo").width();
$(".demo").addClass("foo");
$(".demo").removeClass('foo').addClass('bar');
$(".demo").css({
height: 100,
width: 100,
display: 'block'
});
Y.one(".demo").get("offsetWidth");
Y.one(".demo").addClass("foo");
Y.one(".demo").replaceClass('foo', 'bar');
Y.one(".demo").setStyles({
height: 100,
width: 100,
display: 'block'
});
<div class="demo">this is a div</div>
$(".demo").click(function(e){alert(this);});
$("#id")
.click(function(){
$(this).css({ background: "red" });
})
.mouseout(function(){
$(this).css({ background: "blue" });
});
Y.one(".demo").on('click', function(e){alert(this);});
Y.one("#id").on({
click: function(e) {
this.setStyle("background", "red");
},
mouseout: function(e) {
this.setStyle("background", "blue");
}
});
$.post('http://www.sina.com/', 'name=adam', function(o){});
$("#id").load("ajax.html");
// Advanced
$.ajax({
url: "ajax.html",
type: "GET",
success: function(req){
$("#id").html(req);
}
});
var cfg = {
start: function(){},
complete: function(){},
failure: function(){}
};
Y.io('http://www.sina.com/', cfg);
Y.io("ajax.html",{
method: "GET",
on: {
success: function(id, req, args){
Y.one("#id").setContent(req.responseText);
}
}
});
$("#id").animate(
{ height: 20 },
1500,
"easeOutBounce"
);
new Y.Anim({
node: "#id",
to: {
height: 20,
},
duration: 1.5,
easing: Y.Easing.bounceOut
}).run();
$.browser.msie;
var settings = { validate: false, limit: 5, name: "foo" };
var options = { validate: true, name: "bar" };
$.extend(settings, options);//settings == { validate: true, limit: 5, name: "bar" }
var Developer = $.inherit({
__constructor : function(name){
this.name = name;
this.company = "New Company";
},
task: function(){
return "Development";
},
info: function(){
alert(this.name + ", " + this.task() + ", " + this.company);
}
});
var Designer = $.inherit(Developer, {
task: function(){
return "Design";
}
});
var newDeveloper = new Developer("Tim");
var newDesigner = new Designer("Tom");
neuerDeveloper.info(); // Output: "Tim, Development, New Company"
newDesigner.info(); // Output: "Tom, Design, New Company"
Y.UA.ie;
Y.extend;
Y.augment;
Y.clone;
Y.merge;
Y.mix;
var Developer = Y.Base.create("developer", Y.Base, [], {
task: function(){
return "Development";
},
info: function(){
alert(this.get("name") + ", " + this.task() + ", " + this.get("company"));
}
}, {
ATTRS: {
name: {},
company: {
value: "New Company"
}
}
});
var Designer = Y.Base.create("designer", Developer, [], {
task: function(){
return "Design";
}
});
var newDeveloper = new Developer({ name: "Tim" });
var newDesigner = new Designer({ name: "Tom" });
newDeveloper.info(); // Output: "Tim, Development, New Company"
newDesigner.info(); // Output: "Tom, Design, New Company"
jQuery.fn.customFunction = function(parameter){
this.css({
"background": parameter.color,
"border": parameter.border
});
};
$("#id").customFunction({
color: "red",
border: "3px blue solid"
});
Y.Node.prototype.customFunction = function(parameter){
this.setStyles({
background: parameter.color,
border: parameter.border
});
};
Y.one("#id").customFunction({
color: "red",
border: "3px blue solid"
});
<script type="text/javascript" src="jquery.js"></script>
<script src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
YUI().use('node', function(Y) {
Y.one('#demo');
});
Plugins...
Slider, Tabview, TreeView, ImageLoader, Drag&Drop, Animation...