2017-08-12 62 views
0
<a href="https://jsfiddle.net/krishna2909/amxLak5d/">Clcik here</a> 

在上面的鏈接中,我保留了我正在測試的代碼。如何將點擊功能更改爲懸停功能?如何將onClick更改爲onHover功能?

+0

請包括一個鏈接或一段代碼。沒有內容。 –

+0

對不起,我現在在這裏現在我編輯它 – Krishna2909

+0

我已經在下面添加了一個解決方案。或者,查看重複的建議。 –

回答

1

在這裏,你去了一個解決方案https://jsfiddle.net/amxLak5d/2/

$(function(){ 
 
    $('[rel="popover"]').popover({ 
 
     container: 'body', 
 
\t \t 
 
     html: true, 
 
     content: function() { 
 
      var clone = $($(this).data('popover-content')).clone(true).removeClass('hide'); 
 
      return clone; 
 
     }, 
 
     trigger: "hover" 
 
    }).hover(function(e) { 
 
     e.preventDefault(); 
 
    }); 
 
    
 
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
\t \t <!--How to change Onclick Function to On Hover Function--> 
 
    <nav class="navbar navbar-toggleable-xl navbar-light back_trans100"> 
 
\t \t \t <div class="container-fluid"> 
 
\t \t \t \t <div class="navbar-header"> 
 
\t \t \t \t <a class="navbar-brand" href="#"><img src="images/logo.png" class="img-responsible"></a> 
 
\t \t \t \t </div> 
 
\t \t \t \t <ul class="nav navbar-nav navbar-right"> 
 
\t \t \t \t \t <li class="active"> 
 
\t \t \t \t \t <a href="#" rel="popover" data-placement="bottom" data-popover-content="#myPopover">My Popover</a> 
 
\t \t \t \t \t \t <div id="myPopover" class="hide"> 
 
\t \t \t \t \t \t \t This is a popover list: 
 
\t \t \t \t \t \t \t <ul> 
 
\t \t \t \t \t \t \t \t <li>List item 1</li> 
 
\t \t \t \t \t \t \t \t <li>List item 2</li> 
 
\t \t \t \t \t \t \t \t <li>List item 3</li> 
 
\t \t \t \t \t \t \t </ul> 
 
\t \t \t \t \t \t </div> 
 
\t \t \t \t \t </li> 
 
\t \t \t \t <li><a href="#">Page 1</a></li> 
 
\t \t \t \t <li><a href="#">Page 2</a></li> 
 
\t \t \t \t <li><a href="#">Page 3</a></li> 
 
\t \t \t \t </ul> 
 
\t \t \t </div> 
 
\t \t \t </nav>

只需添加trigger: "hover"屬性。

參考文件:https://www.w3schools.com/bootstrap/bootstrap_ref_js_popover.asp

+0

感謝您的幫助兄弟 – Krishna2909

+0

歡迎好友:) – Shiladitya

+0

這對Shiladitya很有幫助,但在回答之前等待問題在主題上可能會更好。由於我們希望它們是獨立的,因此只有代碼的外部鏈接的問題可能會被封閉。這可以防止未來的鏈路中斷。我的經驗是,一旦新的社區成員得到了他們的答案,他們就不可能編輯這個問題來讓它自成一體。 – halfer

0

變化與酥料餅的元素,包括一個數據觸發和值hover

<a href="#" rel="popover" data-placement="bottom" data-popover-content="#myPopover" data-trigger="hover">My Popover</a> 

https://jsfiddle.net/amxLak5d/1/