BootStrap使用popover插件實現(xiàn)鼠標經(jīng)過顯示并保持顯示框
在商城里,導(dǎo)航欄的購物車展示經(jīng)常需要鼠標經(jīng)過時,顯示已經(jīng)放入購物車的商品,bootstrap是沒有直接用的插件的,這個時候就可以使用popover這個插件改造后實現(xiàn),具體如下:
實現(xiàn)效果圖:
html實現(xiàn):
<a href="#" rel="drevil"> <span class="glyphicon glyphicon-shopping-cart"> </span> 購物車 </a>
javascript實現(xiàn):
$(function(){ $("[rel=drevil]").popover({ trigger:'manual', placement : 'bottom', //placement of the popover. also can use top, bottom, left or right title : '<div style="text-align:center; color:red; text-decoration:underline; font-size:14px;"> Muah ha ha</div>', //this is the top title bar of the popover. add some basic css html: 'true', //needed to show html of course content : '<div id="popOverBox"><img src="http://www.hd-report.com/wp-content/uploads/2008/08/mr-evil.jpg" width="251" height="201" /></div>', //this is the content of the html box. add the image here or anything you want really. animation: false }).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); }); });
以上所述是小編給大家介紹的BootStrap使用popover插件實現(xiàn)鼠標經(jīng)過顯示并保持顯示框,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
js接收并轉(zhuǎn)化Java中的數(shù)組對象的方法
下面小編就為大家?guī)硪黄猨s接收并轉(zhuǎn)化Java中的數(shù)組對象的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-08-08iframe的onload在Chrome/Opera中執(zhí)行兩次Bug的解決方法
創(chuàng)建iframe對象,添加load事件, 再將iframe添加到body中。Chrome/Opera中會造成load事件的handler執(zhí)行兩次。2011-03-03詳解js私有作用域中創(chuàng)建特權(quán)方法
這篇文章主要為大家詳細介紹了js私有作用域中創(chuàng)建特權(quán)方法,何為特權(quán)方法,特權(quán)方法就是有權(quán)訪問私有變量和私有函數(shù)的公有方法,感興趣的小伙伴們可以參考一下2016-01-0120170918 前端開發(fā)周報之JS前端開發(fā)必看
本文給大家分享了最新版js 前端開發(fā)周報,內(nèi)容非常不錯,具有參考借鑒價值,需要的朋友參考下吧2017-09-09