18
悬停时如何保持Bootstrap弹出窗口的生命?
我正在使用Bootstrap弹出窗口来创建显示用户信息的悬停卡,并在将鼠标悬停在按钮上时触发它。我想在悬停弹出窗口时保持该弹出窗口的活动,但是一旦用户停止将鼠标悬停在按钮上,它就会消失。我怎样才能做到这一点? $('#example').popover({ html : true, trigger : 'manual', content : function() { return '<div class="box">Popover</div>'; } }); $(document).on('mouseover', '#example', function(){ $('#example').popover('show'); }); $(document).on('mouseleave', '#example', function(){ $('#example').popover('hide'); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js"></script> <script src="https://unpkg.com/@popperjs/core@2"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/> <a href="#" id="example" class="btn btn-danger" rel="popover" >hover for popover</a> 运行代码段隐藏结果展开摘要