Bootstrap popover 實現鼠標移入移除顯示隱藏功能

版權聲明:本文爲博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/Q718330882/article/details/72123754

該段js代碼可實現 popover  下鼠標移入移除時顯示、隱藏 popover  提示信息功能


var strContent = '<div class="media"><div class="position-left media-left"><img class="img-circle" src="/assets/images/avatar.jpg">'+
                  '</div>'+
                  '<div class="media-body">'+
                    '<h4 class="media-title">小標題</h4>'+
                    '<p><strong>張三</strong> <span class="label label-primary">管理員</span></p>'+
                  '</div>'+
                  '</div>';
$( 'li#user_avatar' ).popover({
    trigger:'manual',
	placement:'bottom',
	html:true,
	container:'#bs-example-navbar-collapse-1',
	content:strContent,
}).on( 'mouseenter', function(){  
    var _this = this;  
    $(this).popover( 'show' );  
    $(this).siblings( '.popover' ).on( 'mouseleave' , function () {  
        $(_this).popover( 'hide' );  
    });  
}).on( 'mouseleave', function(){  
    var _this = this;  
    setTimeout(function () {  
        if (!$( '.popover:hover' ).length) {  
            $(_this).popover( 'hide' )  
        }
    }, 100);  
});


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章