Smooth scroll external link with id

Smooth scroll external link with id

I found this fiddle  http://jsfiddle.net/tovic/kw7LD/  that shows how to apply smooth scroll to external link with  class . I'd like to know if is possible apply the same effect using  id  instead of  classes .
  1. $(window).on("load", function () {
  2.     var urlHash = window.location.href.split("#")[1];
  3.     $('html,body').animate({
  4.         scrollTop: $('.' + urlHash).offset().top
  5.     }, 4000);
  6. });