Description: The following code is intended to always scan the Web page for the presence of the element you are looking for, always traverse the loop lookup!
$ (function () {
jQuery.fn.wait = function (func, times, interval) {
var _times = Times | | -1,//100 times
_interval = Interval | | 20,//20 milliseconds per
_self = this,
_selector = this.selector,//Selector
_iintervalid; Timer ID
if (this.length) {//If you have already obtained it, execute the function directly
Func && Func.call (this);
} else {
_iintervalid = setinterval (function () {
if (!_times) {//Is 0 exit
Clearinterval (_iintervalid);
}
_times <= 0 | | _times--; If it's a positive number--
_self = $ (_selector); Select again
if (_self.length) {//to decide whether to take
Func && Func.call (_self);
Clearinterval (_iintervalid);
}
}, _interval);
}
return this;
}
$ ("#win_cs_pannel"). Wait (function () {
Window.Scroll (0, 605)
});
})
not going to the meeting, just a process!
This article is from the "Happy and simple" blog, make sure to keep this source http://1120173856.blog.51cto.com/2882946/1637471
Does jquery traverse elements exist