我在MVC页面上有一个ListBox
:
@Html.ListBox("lstFacilitySelection", Model.FacilityOptionList, new { id = "FacilityListBox", Multiple = "multiple", Size = 5, style = "width: 50%;" })
如何为此ListBox禁用鼠标滚轮滚动,以便必须使用控件侧面的滚动条?
编辑:Ashwini Verma提出的解决方案略有修改:
$(document).ready(function () {
$('#FacilityListBox').on({
'mousewheel': function (e) {
if (e.target.id == 'el') return;
e.preventDefault();
e.stopPropagation();
}
})
});
答案 0 :(得分:1)
您可以使用jquery禁用它。 See working demo here
<div class="scrollable"> </div>
$(document).ready(function(){
$('body').on({
'mousewheel': function(e) {
if (e.target.id == 'el') return;
e.preventDefault();
e.stopPropagation();
}
})
});