Created
April 4, 2018 18:34
-
-
Save chered/76ac357e7cc21e8434350b69da7bf118 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This JavaScript code can be added into Divi using the integration option at: > Theme Options > Integration >"Add code to the < head > of your blog", and as a result will survive theme updates. | |
<script> | |
document.addEventListener('DOMContentLoaded', function(event){ | |
if (window.location.hash) { | |
// Start at top of page | |
window.scrollTo(0, 0); | |
// Prevent default scroll to anchor by hiding the target element | |
var db_hash_elem = document.getElementById(window.location.hash.substring(1)); | |
window.db_location_hash_style = db_hash_elem.style.display; | |
db_hash_elem.style.display = 'none'; | |
// After a short delay, display the element and scroll to it | |
jQuery(function($){ | |
setTimeout(function(){ | |
$(window.location.hash).css('display', window.db_location_hash_style); | |
et_pb_smooth_scroll($(window.location.hash), false, 800); | |
}, 700); | |
}); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment