jQuery isChildOf

(function($) {
$.fn.extend({
isChildOf: function( filter_string ) {

var parents = $(this).parents().get();

for ( j = 0; j < parents.length; j++ ) {
if ( $(parents[j]).is(filter_string) ) {
return true;
}
}

return false;
}
});
})(jQuery);

Beispiel

<div id="parent2">
<div id="parent1">
<div id="child">
</div>
</div>
</div>

alert( $('#child').isChildOf('#parent1') );

 

Trigger Start and End of scrolling

var t, l = (new Date()).getTime();

$(window).scroll(function(){
var now = (new Date()).getTime();

if(now - l > 400){
$(this).trigger('scrollStart');
l = now;
}

clearTimeout(t);
t = setTimeout(function(){
$(window).trigger('scrollEnd');
}, 300);
});

$(window).bind('scrollStart', function(){
console.log('scrollStart');
});

$(window).bind('scrollEnd', function(){
console.log('scrollEnd');
});

http://jsfiddle.net/yijiang/fGmbe/