From 0d39c4303c00193b9530335c38b3797647015c97 Mon Sep 17 00:00:00 2001 From: Simon Holywell Date: Mon, 6 Jul 2015 17:01:00 +0100 Subject: [PATCH] Prevent error when access non-existent dom elements --- scripts.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts.js b/scripts.js index cddb95a..3569d55 100644 --- a/scripts.js +++ b/scripts.js @@ -19,7 +19,9 @@ $(document).ready(function(){ var dest = 0; if(target) { var $target = $(target); - dest = $target.offset().top; + if($target.length) { + dest = $target.offset().top; + } } $('html, body').stop().animate({