【问题标题】:Showing Map Tooltip by seconds按秒显示地图工具提示
【发布时间】:2022-10-14 23:13:00
【问题描述】:

我有一个简单的地图,当单独单击时,工具提示将显示(和隐藏):

我的问题是我希望该工具提示在不点击的情况下自行显示一定的秒数。但我不知道该怎么做。

这是我的代码:

$( document ).ready(function() {
$(".states-img").click(function() {
  showtooltip = $(this).attr('location');
  $(".map-tooltip").removeClass("showtooltip");
  $("."+showtooltip+"").addClass("showtooltip");
  console.log(showtooltip);
}); });

【问题讨论】:

    标签: javascript jquery


    【解决方案1】:

    尝试使用.hover() 而不是.click()

    $(document).ready(function() {
      $(".states-img").hover(function() {
        showtooltip = $(this).attr('location');
        $(".map-tooltip").removeClass("showtooltip");
        $("." + showtooltip + "").addClass("showtooltip");
        console.log(showtooltip);
      }, function() {
        showtooltip = $(this).attr('location');
        $("." + showtooltip + "").removeClass("showtooltip");
        $(".map-tooltip").addClass("showtooltip"); // evaluate if really needed
      });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-29
      • 1970-01-01
      • 2016-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多