【发布时间】:2012-02-01 12:25:57
【问题描述】:
我已经使用了 sizzle 的示例,并且我在最后的代码中得到了 window.onload。
这是什么意思。
我的代码是这样的:
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() 仅在窗口(页面)加载完成后才开始工作。
标签: jquery