From ef78a1e6c8320f9cd3ace34039a32d0d43f0a582 Mon Sep 17 00:00:00 2001 From: Shreya Ajith Date: Fri, 15 Oct 2021 20:15:13 +0530 Subject: [PATCH] fixed the redundant var --- js/main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/main.js b/js/main.js index 3a0876e..a2a0f62 100644 --- a/js/main.js +++ b/js/main.js @@ -16,12 +16,12 @@ $(document).ready(function(){ e.preventDefault(); var target = this.hash, - $target = $(target); - - $('html, body').animate({ - 'scrollTop': $target.offset().top-80 - }, 400, 'swing', function () { + if($(target).length){ + $('html, body').animate({ + 'scrollTop': $(target).offset().top - 80 + }, 400, 'swing'); + } }); }); - }); +