0
我使用tinyscrollbar和script。我想在我的頁面上有一個按鈕,它應該在點擊時模擬鼠標滾輪。我認爲這是應該調用的tinyscrollbar腳本中的函數wheel(event)
。我怎樣才能做到這一點?點擊調用特殊的jQuery函數
$("#clickit").click(wheel);
但這不起作用
我使用tinyscrollbar和script。我想在我的頁面上有一個按鈕,它應該在點擊時模擬鼠標滾輪。我認爲這是應該調用的tinyscrollbar腳本中的函數wheel(event)
。我怎樣才能做到這一點?點擊調用特殊的jQuery函數
$("#clickit").click(wheel);
但這不起作用
嘗試
$(文件)。就緒(函數(){
$("#clickit").click(function(){
$('#your_tinyscrollbar_id').wheel(); //Your function call
});
});
[更新]
您不能:這個功能實際上是私人的,只有在更新功能中訪問。
下面是一個描述初始化tinyscrollbar
:
$('#your_scrollbar').data('tsb') //Object description
Scrollbar {update: function}
update: function (sScroll)
arguments: null
caller: null
length: 1
name: ""
prototype: Object
__proto__: function Empty() {}
<function scope> //Private functions, accessible
Closure //only within the scope of the
drag: function drag(event) //update function
end: function end()
iMouse: Object
iPosition: Object
iScroll: 0
oContent: Object
oScrollbar: Object
oSelf: Scrollbar
oThumb: Object
oTrack: Object
oViewport: Object
oWrapper: p.fn.p.init[1]
options: Object
sAxis: false
sDirection: "top"
sSize: "Height"
setEvents: function setEvents()
setSize: function setSize()
start: function start(event)
touchEvents: false
wheel: function wheel(event)
Closure
Global: Window
__proto__: Scrollbar
感謝,但不工作 – matin 2013-03-13 13:27:29
@matin嘗試更加明確的請:什麼不起作用? 「click」事件是否觸發?調用'wheel()'函數?檢查你的javascript調試器 – Bigood 2013-03-13 13:36:10
點擊確實有效。如果我使用$(「#clickit」)。click(function(){ \t alert('d'); \t});顯示警報。但是如果我使用$(「#clickit」)。click(function(){ \t wheel(); \t alert('d'); \t});沒有警告顯示,功能輪似乎不被稱爲,因爲我也把這個功能的警報。如果正在滾動鼠標滾輪,則會顯示函數輪中的警告 – matin 2013-03-13 13:41:52