Tuesday, January 29, 2013

Animate div with browser scroll


precurscrol = 0;
$(window).scroll(function () {
    //You've scrolled this much:

totalscroll = $(document).height() - $(window).height();
        curscrol = $(window).scrollTop();
if(curscrol<(totalscroll-115))
{
if(precurscrol>curscrol){ curscrol = curscrol+100;  }
if(curscrol>70 )
{
$("#leftbar").css({'margin-top':curscrol+'px'});
curscrol = curscrol-20;
//$("#leftbar").animate({'margin-top':curscrol+'px'},'fast',function () {})
}
precurscrol = curscrol;
//console.log(precurscrol);

}

});

Bind Some Event to Element and trigger that function when click the element

Scenario: Suppose if we used same click event function in various web pages. if you want do some logic some page button for that need to re...