【问题标题】:Change mouse cursor when hover on plot item将鼠标悬停在绘图项目上时更改鼠标光标
【发布时间】:2011-12-16 03:28:01
【问题描述】:

我想知道在鼠标悬停在绘图项上时更改鼠标光标的最佳方法是什么,以及在远离绘图项时将光标更改回默认值的最佳方法

plot.bind("plothover", function(event, pos, item) {
            if(item) {
                document.body.style.cursor = 'pointer';
                    } else {
                            document.body.style.cursor = 'pointer';
                    }
 }

一开始可以用,但是平移后就不行了……

【问题讨论】:

    标签: hover flot mouse-cursor


    【解决方案1】:

    你很亲密。您的第二个光标设置行不正确。这是一个更正的版本:

    plot.bind("plothover", function(event, pos, item) {
        if(item) {
            document.body.style.cursor = 'pointer';
        } else {
            document.body.style.cursor = 'default';
        }
    }
    

    【讨论】:

      【解决方案2】:

      如果您指向不同的页面,光标设置将保留为指针。而是使用 floatcontainer 本身来设置光标样式。

      $("#flotcontainer").bind("plothover", function(event, pos, item) {
        if(item)
          $("#flotcontainer").css("cursor","pointer","important");
        else
          $("#flotcontainer").css("cursor","default", "important");
      });
      

      【讨论】:

      • 'important' 通常是不必要的,之后要清除光标,您应该使用空字符串而不是 'default',以免覆盖任何其他样式容器。
      猜你喜欢
      • 2012-09-22
      • 1970-01-01
      • 2021-11-27
      • 2022-01-26
      • 1970-01-01
      • 2017-08-14
      • 1970-01-01
      • 2021-04-10
      • 1970-01-01
      相关资源
      最近更新 更多