I'm working on updating jQuery for a really old wordpress site. I have the function below that I'm trying to rewrite:
$(".smscroll").click(function(event){
event.preventDefault();
// CALCULATE DESTINATION PLACE
var dest = 0;
if ($(this.hash).offset().top > ($(document).height() - $(window).height()))
{
dest = $(document).height() - $(window).height();
}
else
{
dest = $(this.hash).offset().top;
}
// GO TO DESTINATION
$('html,body').animate({scrollTop:dest}, 1000, 'swing');
});
I realize that .click is deprecated. So, I'm trying to replace it with the following:
$(document).on("click", ".smscroll", function(event){
event.preventDefault();
// CALCULATE DESTINATION PLACE
var dest = 0;
if ($(this.hash).offset().top > ($(document).height() - $(window).height()))
{
dest = $(document).height() - $(window).height();
}
else
{
dest = $(this.hash).offset().top;
}
// GO TO DESTINATION
$('html,body').animate({scrollTop:dest}, 1000, 'swing');
});
What else do i need to clean up to get rid of the deprecation?