我试图在HTML5日期输入上禁用滚动,但没有成功。
这个输入有一个webshim回退,这使得我的JS可以使用Chrome,而不是Firefox。
$('.input-date input').on('mousewheel', function (event) {
event.preventDefault();
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/webshim/1.15.6/dev/polyfiller.js"></script>
<script type="text/javascript">
webshims.cfg.no$Switch = true;
webshim.setOptions({
'forms-ext': {
widgets: {
calculateWidth: false
}
}
});
webshim.polyfill('forms forms-ext');
</script>
<form>
<div class="input-date">
<input type="date" value="2015-02-24">
</div>
</form>
有没有人面临过这个问题?
发布于 2015-02-25 08:39:59
我有机会和webshim的作者讨论过这个问题,并发现可以选择避免这类问题:noSpinbtn。
因此,代码将如下所示:
$('.input-date input').on('mousewheel', function (event) {
event.preventDefault();
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/webshim/1.15.6/dev/polyfiller.js"></script>
<script type="text/javascript">
webshims.cfg.no$Switch = true;
webshim.setOptions({
'forms-ext': {
widgets: {
calculateWidth: false
},
date: {
noSpinbtn: true
}
}
});
webshim.polyfill('forms forms-ext');
</script>
<form>
<div class="input-date">
<input type="date" value="2015-02-24">
</div>
</form>
https://stackoverflow.com/questions/28697491
复制相似问题