我使用滋滋的例子,在那里我得到了在最后的代码的window.onload。在window.onload jQuery中
这是什么意思。
我的代码是这样的:
var init = function() {
var trail = Sizzle;
var foo = trail('.foo');
foo[0].onmouseover = function() {
this.style.backgroundColor = (this.style.backgroundColor.indexOf('blue') === 0) ? 'yellow' : 'blue';
};
foo[1].onmouseover = function() {
this.style.backgroundColor = (this.style.backgroundColor.indexOf('red') === 0) ? 'yellow' : 'red';
jQuery(foo[1]).after("<b>Hello</b>");
}
foo[2].onmouseover = function() {
this.style.backgroundColor = (this.style.backgroundColor.indexOf('green') === 0) ? 'yellow' : 'green';
jQuery(foo[3]).toggle("slow");
jQuery('b').remove();
}
};
window.onload = init;
这是什么意思?
函数init()只在窗口(页面)加载完成后才开始工作。 – Narek 2012-02-01 12:27:21