单击所选容器时,在模态体中滚动并设置div

我在模态中有一个表单,我用选择的jquery格式化我的选择框

当我点击选定的容器时,我想将div滚动到模态体的顶部

我的表格在这里

在此处输入图像描述

当点击选择的容器时,我想通过jquery这种类型的滚动

在此处输入图像描述

我试着这样做:

//$(document).on('click','.search-field',function(){ $(document).on('click','.chosen-choices',function(){ console.log("ok"); // $(this).animate({scrollTop: $(this).closest('.modal-body').offset().top},'slow'); // $('body').animate({scrollTop: $(this).closest('.modal-body').offset().top},'slow'); $('.modal-body').animate({scrollTop: $(this).closest('.modal-body').offset().top},'slow'); // $(this).closest('.chosen-container').animate({scrollTop: $(this).closest('.modal-body').offset().top},'slow'); // $(this).scrollTop(0); }); 

如果我点击项目经理选择框,那么它应该固定在顶部,如果我点击转包商,那么它应该固定在顶部。

请帮我这样做。