[英]Disable mouse wheel scrolling on ListBox
我在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();
}
})
});
您可以使用jquery禁用它。 在這里查看工作演示 。
<div class="scrollable"> </div>
$(document).ready(function(){
$('body').on({
'mousewheel': function(e) {
if (e.target.id == 'el') return;
e.preventDefault();
e.stopPropagation();
}
})
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.