这次给大家带来jquery在输入框查找关键字并高亮,jquery在输入框查找关键字并高亮的注意事项有哪些,下面就是实战案例,一起来看一下。
实例代码如下所示:
<p>
<a class="btn btn-success show" title="popover title"
data-container="body" data-toggle="popover" data-placement="bottom"
data-content="底部的 popover 中的一些内容"> aaaa </a>
</p>
<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、取消冒泡
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
jquery.picsign组件使用详解
jquery给子元素添加赋值步奏详解
js在移动端实现无限加载分页功能
以上就是jquery在输入框查找关键字并高亮的详细内容。