I know jquery support delegate function for add and remove a function custom follow event. EX
$("body").delegate("#p", "click", cfunc);
but how to delegate function when page loaded ?
edited——
I show more ex code for more detail in my question: 🙂
i have a function custom name = cfunc()
now i need call it when page load for run many many event inside it.
on the time page loaded, viewer make some event (ex: resize, scroll …) i need undelegate cfunc() and call again with some new var.
— edit 2 —–
sorry everyone, i will write done more code :
this is function i want to delegate
function bbbb_scroll(pos)
{
$(document).scroll(function() {
var _currentpos = $(window).scrollTop();
if (_currentpos > pos) {
console.log('match');
}
});
}
now i want add it on to page when stage READY
$(document).ready(function() {
$(window).delegate("body", "resize", bbbb_scroll);
});
after all, when user resize the window of browser, i need undelegate bbbb_scroll function and call again with new var ( on pos variable )
http://api.jquery.com/on/
http://api.jquery.com/ready/