jquery 输入框查找关键字并提亮颜色的实例代码
实例代码如下所示:
<div>
<a class="btn btn-success show" title="Popover title"
data-container="body" data-toggle="popover" data-placement="bottom"
data-content="底部的 Popover 中的一些内容"> aaaa </a>
</div>
<script>
$(function () {
initPopover();
})
function initPopover() {
$(".show").popover({
container: "body",
trigger: " manual" //手动触发
}).on('show.bs.popover', function () {
$(this).addClass("popover_open");
}).on('hide.bs.popover', function () {
$(this).removeClass("popover_open");
});
$(".show").click(function () {
if ($(this).hasClass("popover_open")) {
$(this).popover("hide")
} else {
$(".popover_open").popover("hide");
$(this).popover("show");
}
var e = arguments.callee.caller.arguments[0] || event;
e.stopPropagation();
});
$(document).click(function () {
$(".show").popover("hide");
});
}
</script>注意点:
1、不适用于button,a、img等可用
2、show.bs.popover:当调用show 实例方法时立即触发该事件。
shown.bs.popover:当弹出框对完全弹出时触发该事件(将等待 CSS 过渡效果完成)。
hide.bs.popover:当调用hide 实例方法时立即触发该事件。
hidden.bs.popover:当工具提示完全隐藏时触发该事件(将等待 CSS 过渡效果完成)。
3、引入jquery和bootstrap头文件
4、取消冒泡
相关推荐
85477104 2020-08-15
delmarks 2020-06-28
89510194 2020-06-27
牵手白首 2020-06-14
tztzyzyz 2020-05-31
81463166 2020-05-17
88570299 2020-05-17
delmarks 2020-05-17
donghongbz 2020-05-15
tztzyzyz 2020-05-15
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" width="100%&qu
牵手白首 2020-05-14
Chriswang 2020-04-30
83510998 2020-05-03