2013-03-13 60 views
0

我使用tinyscrollbarscript。我想在我的页面上有一个按钮,它应该在点击时模拟鼠标滚轮。我认为这是应该调用的tinyscrollbar脚本中的函数wheel(event)。我怎样才能做到这一点?点击调用特殊的jQuery函数

$("#clickit").click(wheel); 

但这不起作用

回答

1

尝试

$(文件)。就绪(函数(){

$("#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 
+0

感谢,但不工作 – matin 2013-03-13 13:27:29

+1

@matin尝试更加明确的请:什么不起作用? “click”事件是否触发?调用'wheel()'函数?检查你的javascript调试器 – Bigood 2013-03-13 13:36:10

+0

点击确实有效。如果我使用$(“#clickit”)。click(function(){ \t alert('d'); \t});显示警报。但是如果我使用$(“#clickit”)。click(function(){ \t wheel(); \t alert('d'); \t});没有警告显示,功能轮似乎不被称为,因为我也把这个功能的警报。如果正在滚动鼠标滚轮,则会显示函数轮中的警告 – matin 2013-03-13 13:41:52