![](/img/trans.png)
[英]How to disable canvas elements from hijacking mouse wheel when scrolling through a page?
[英]JQuery: How to disable mouse over scrolling on all <select> elements on a page
以下代碼似乎不起作用。 我在這里錯過了什么?
<script type="text/javascript" language="javascript">
//disables scrolling on mouse over of <select> elements
$(document).ready(function() {
$('select').each(function() {
$(this).attr('onmousewheel', 'return false;');
});
});
</script>
你可以試試這個:
<script type="text/javascript" language="javascript">
//disables scrolling on mouse over of <select> elements
$(document).ready(function() {
$('select').each(function() {
$(this).on('mousewheel', function(){
return false;
});
});
});
</script>
onmousewheel實際上不是SELECT HTML Element的一個屬性。 請參閱http://www.w3schools.com/tags/tag_select.asp
您正在嘗試設置鼠標事件。 http://www.w3schools.com/tags/ref_eventattributes.asp
您可以通過MISJHA指出的方式實現這一目標。
嘗試removeAttr 。 它刪除附加的DOM屬性
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.