我嘗試使用 jQuery (jquery-1.7.1.min.js) 滾動(dòng),mouseover但無法滾動(dòng)。下面是我的代碼。var ele = $('html,body');var speed = 1, scroll = 3, scrolling;$('#up').mouseenter(function() { //scroll the element up scrolling = window.setInterval(function() { ele.scrollTop(ele.scrollTop() - scroll); }, speed);});$('#down').mouseenter(function() { //scroll the element down scrolling = window.setInterval(function() { ele.scrollTop(ele.scrollTop() + scroll); }, speed);});$('#up, #down').bind({ click: function(e) { //stop scrolling if (scrolling) { //prevents the default click action e.preventDefault(); } }, mouseleave: function() { if (scrolling) { window.clearInterval(scrolling); scrolling = false; } }});.control { width: 100%; position: fixed; text-align: center}#up.control { position: fixed; top: 0}#down.control { position: fixed; top: 20}/* no needed: */#scroll { overflow-x: scroll; width: 500px; white-space: nowrap; overflow: hidden!imprtant;}onmouse左側(cè)和右側(cè)需要從左到右和從左到右滾動(dòng)文本,但它無法使用 jQuery。
- 0 回答
- 0 關(guān)注
- 117 瀏覽
添加回答
舉報(bào)
0/150
提交
取消