I want to Change 'affix' offset-top by clicking on a button by jQuery.
$('#nav2').affix({
offset: {
top: $("#nav1").height()+58
}
});
is working well, but I can't change the top value after loading my page containing the code.
You could do it like so:
Edit to answer your suggestion, Bootstrap affix documentation claims:
So there is no need to remove all the classes and re-initialize
affix. Just use the code snippet above.More about Bootstrap
affixcan be found here.A best option will be to set it thur css:
And then with jQuery change the top position only:
Hope it helps.