$(function() { var initMatchHeight = function(){ if(typeof $.fn.matchHeight !== "undefined"){ var mh_target_list = []; $("[class*=js-matchHeight]").each(function(){ var reg = /^js-matchHeight+/; var class_list = $(this).attr("class").split(/\s+/); var str = ""; for(var i = 0; i < class_list.length; i++){ if(reg.test(class_list[i])){ str = class_list[i]; } } if(str){ mh_target_list.push(str); } }); if(mh_target_list){ var mh_exec_classes = mh_target_list.filter(function(elm, index, arr){ return arr.indexOf(elm) === index; }); for(var j = 0; j < mh_exec_classes.length; j++){ $("." + mh_exec_classes[j]).matchHeight(); } } } }; MicroModal.init({ disableScroll: true, disableFocus: true, awaitCloseAnimation: true, awaitOpenAnimation: true, }); initMatchHeight(); $('.js-modal-target').on('click',() => { initMatchHeight(); }) }); $('a[href^="#"]').on('click', function () { event.preventDefault(); let href= $(this).attr('href'); let target = $(href == '#' || href == '' ? 'html' : href); let position = target.offset().top; $('body,html').animate({scrollTop:position}, 500, 'swing'); });