jquety如何使用scrolltop

.在jquery中,我如何实现利用滚动条到达一定位置时,执行事件。

 $(selector).scrollTop(offset)

$(selector).scroll(function(){
var viewH =$(this).height();//可见高度
var contentH =$(this).get(0).scrollHeight;//内容高度

var scrollTop =$(this).scrollTop();//滚动高度
//TODO:判断高度

});

$(selector).scroll(function(){
var viewH =$(this).height();//可见高度
var contentH =$(this).get(0).scrollHeight;//内容高度

var scrollTop =$(this).scrollTop();//滚动高度

});

https://zhidao.baidu.com/question/514933624.html

参考。

参考下面的:
var top=$("#menu-layoutit").offset().top;
$(window).scroll(function () {
if ($(window).scrollTop() >= top) {
$("#menu-layoutit").attr("style", "position:fixed;top:27px;left:55px;z-index:10;");
} else {
$("#menu-layoutit").attr("style", "");
}
}).trigger("scroll");

这种效果吧?
javascript滚动到导航条时如何固定在顶部