Hi peeps wondering if anyone could help me with a click function, should animate to the target anchor which it does fine when using an integer for the scrollTop value however when I pass a variable it doesnt like it. Any ideas?
$(".project a").click(function(event){
event.preventDefault();
var full_url = this.href;
var parts = full_url.split("#");
var trgt = parts[1];
var target_offset = $("#"+trgt).offset();
var target_top = target_offset.top; //- 90;
$('html, body').animate({scrollTop:target_top}, 1000, function() {
});
});
FIXED: Ok apologies peeps the function was working fine from the get go however a colleague has pointed out var trgt contained an element that was set to display:none in the css, with the original intention of using slideToggle on callback... massive sigh. Cheers for your responses though!