You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将Popover触发方式改为Hover的技术需求及相关代码说明

How to Change Popover Trigger to Hover

Got it, let's adjust your popover to trigger on hover instead of the default click. Here's the tweaked code and a quick breakdown of what changed:

Modified JavaScript Code

$(document).ready(function () { 
    Address.initialize(); 
    Note.initializeIndex(); 
    Child.initializeEditBillPayer(); 
    AuditLog.Initialise(); 

    if ($(".aged-debetors").length !== 0) { 
        // First set the popover content, then initialize with hover trigger
        $('.aged-debetors-label').attr("data-content", $(".aged-debetors").html());
        $("[data-toggle=popover]").popover({
            trigger: 'hover', // This switches the trigger to hover
            delay: { show: 200, hide: 500 } // Optional: Adds smooth delay to avoid flickering
        }); 
    } 
}); 

Key Adjustments Explained

  • Added trigger: 'hover' to the popover initialization: This tells Bootstrap to show/hide the popover when the user hovers over the label, instead of requiring a click.
  • Optional delay property: This small timing buffer makes the popover feel more natural—prevents it from popping up/disappearing instantly if your mouse moves quickly over the element.

Your HTML Stays the Same

<span class="label label-info aged-debetors-label" 
      data-toggle="popover" 
      data-placement="auto right" 
      data-html="true" 
      data-content="" 
      data-original-title="" 
      title=""> 
    当前余额:@Html.DisplayFor(modelItem => Model.TotalUnpaidAmount) 
</span>

Swap out your original JavaScript with the modified version, and your popover will now activate on hover!

内容的提问来源于stack exchange,提问作者user8788939

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:09:25