나는 sizzle 예제를 사용하고 거기에 마지막 코드에서 window.onload가 있습니다.jQuery에서 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()은 창 (페이지)로드 완료 후에 만 작동하기 시작합니다. – Narek