I'm having this little function which sets a div to position:fixed after a link is clicked.
$(window).load(function(){
$('#linktofreeze').click(function() {
var ftop = $('#fixedbox').offset().top - $(window).scrollTop();
var fleft = $('#fixedbox').offset().left;
$('#fixedbox').css({position: 'fixed', left: fleft + 'px', top: ftop + 'px'});
});
});
What I'm trying to achieve now, is to make the whole thing backwards: When a second link is clicked, the div's position shouldn't be 'fixed' anymore.
What is the best way to do this? Is there a way to delete/remove this function 'onClick' again?
To make it more clear, I uploaded the files on jsFiddle: http://jsfiddle.net/hZX5h/72/
Would be great if anyone could help. Thanks!