how to pass callback with variables?

how to pass callback with variables?

how to pass callback with variables? 



  1. function scrollToElement(element, offSet, callback) {
  2.     $('html, body').animate({
  3.         scrollTop: $(element).offset().top + offSet
  4.     }, 800, function () { if (callback) callback(); });
  5. }
  6. //and from some function i call:
  7. scrollToElement($p, -80, function () {
  8.         openTv($p)
  9.     });