Fix JavaScript error when search is not enabled (#66)

Check `mySearchToggle` exists before calling `addEventListener()` to prevent error when search toggle does not exist.
This commit is contained in:
Tony Ho 2018-07-21 02:33:06 +10:00 committed by Michael Rose
parent 4a73bdb597
commit c5623e2f38
1 changed files with 5 additions and 3 deletions

View File

@ -60,9 +60,11 @@ myMenu.addEventListener('click', function () {
toggleClassMenu(); toggleClassMenu();
animateMenuItems(); animateMenuItems();
}, false); }, false);
mySearchToggle.addEventListener('click', function () { if (mySearchToggle) {
mySearchToggle.addEventListener('click', function () {
toggleClassSearch(); toggleClassSearch();
}, false); }, false);
}
// Toggle search input and content visibility // Toggle search input and content visibility
function toggleClassSearch() { function toggleClassSearch() {