- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面给出的代码包含一个按钮。单击按钮时,会显示一个带有硬编码详细信息的弹出窗口。
弹出窗口是否可以从按钮属性中获取详细信息,例如data-name = "Vikas"data-content = "他是学生"data-dp = "../dp.jpg"
第二个问题是,当用户再次单击按钮时,弹出窗口会关闭。是否有可能停止它,而不是我们可以在弹出窗口中提供一个关闭按钮,并在单击它时弹出窗口应该关闭。
非常感谢您的帮助。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('[data-toggle="popover"]').popover({
placement: 'top',
html: true,
title: 'User Info <a href="#" class="close" data-dismiss="alert">×</a>',
content: '<div class="media"><a href="#" class="pull-left"><img src="../images/avatar-tiny.jpg" class="media-object" alt="Sample Image"></a><div class="media-body"><h4 class="media-heading">Jhon Carter</h4><p>Excellent Bootstrap popover! I really love it.</p></div></div>'
});
$(document).on("click", ".popover .close", function() {
$(this).parents(".popover").popover('hide');
});
});
</script>
<style type="text/css">
.bs-example {
margin: 160px 10px 0;
}
.popover-title .close {
position: relative;
bottom: 3px;
}
</style>
</head>
<body>
<div class="bs-example">
<button type="button" class="btn btn-primary" data-toggle="popover">Click Me</button>
</div>
</body>
</html>
最佳答案
只是一个例子,应该对你有帮助:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('[data-toggle="popover"]').popover({
placement: 'top',
html: true,
title: function() {
return $(this).data('title') + '<a href="#" class="close" data-dismiss="alert">×</a>';
},
content: function() {
return $(this).data('content');
}
});
$(document).on("click", ".popover .close", function() {
$(this).parents(".popover").popover('hide');
});
});
</script>
<style type="text/css">
.bs-example {
margin: 160px 10px 0;
}
.popover-title .close {
position: relative;
bottom: 3px;
}
</style>
</head>
<body>
<div class="bs-example">
<button type="button" class="btn btn-primary" data-toggle="popover" data-title="Custom Title" data-content="Custom Content">Click Me</button>
</div>
</body>
</html>
trigger
参数:How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. manual cannot be combined with any other trigger.
关于javascript - 如何使用 jquery 或 JavaScript 将元素属性与 Bootstrap Popover html 绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35909375/
这里是 sandbox Antd pop over 正如您在示例中看到的,当您单击任意位置时,popover自动关闭。我想禁用该东西并仅通过单击按钮将其关闭。 我在 Popover 中没有看到这样的选
我在 gridview 更新、排序、分页方面遇到错误。页面加载时,网格通过 AJAX 正常加载。但是,在单击标题对行进行排序或单击任何分页按钮时,我收到一条错误消息: Uncaught Typ
我有一个标准的 Ionic 4 页面(主页),它创建一个使用组件(BusinessDetails)和一个重定向到新页面(RequestTurn)的按钮的弹出窗口。但是,当我单击该按钮时,弹出窗口不会消
我为 bootstrap twitter 库调用了 js 文件,但我得到了指示的错误 $("a[rel=popover]").popover is not a function .
Apple 的“移动人机界面指南”是关于弹出框的: When possible, allow people to close one popover and open a new one with o
如果 .popover() 之后变成 .on('hidden.bs.popover'),我想'销毁'是 .on('shown.bs.popover' 所以它不会再 'show' 。一切似乎都正确,但看
我将 emberjs 与 twitter-bootstrap 一起使用,但只有 css,所以没有从 bootstrap 获取的 javascript。 我想让 popover 工作,它弹出了,但是 p
我正在使用 twitter bootstrap 在社交媒体上分享我的帖子,我创建了一个链接,其弹出窗口带有一些按钮内容,但是当我进一步点击弹出窗口中的按钮时,它们的弹出窗口功能不起作用。 Share
我有一些动态加载到包含弹出窗口的网页上的内容。出于这个原因,我必须将它们绑定(bind)到 body 上,以便它们正确加载和显示。 我想找到一种方法来在用户点击弹出窗口外或另一个弹出窗口触发器时隐
当用户点击弹出窗口外的任何地方时,我试图隐藏 Bootstrap 弹出窗口。 (我真的不确定为什么 Bootstrap 的创建者决定不提供此功能。) 我找到了以下代码 on the web但我真的不明
这里是material-ui的例子https://material-ui.com/utils/popover/#mouse-over-interaction 按照示例 material-ui 的这些步
我在表单中使用 Bootstrap 弹出窗口来显示一些仅适用于某些用户的可选选择。我注意到一个问题,即一旦弹出窗口关闭,表单选择(是或否单选按钮选项)就会丢失,并且 2 个单选按钮的表单输入不包含在表
当popover 出现 时如何显示背景,而当popover 消失 时如何显示背景? $(function(){ var content = 'Pay Now Activation Cod
jsFiddle:http://jsfiddle.net/kAYyR/ 截图: 这是有效的: 点击按钮打开弹出框 在弹出框外点击关闭弹出框 点击 .close 按钮关闭弹出窗口 但是...当您再次单击
当尝试使用此模板在一行中显示弹出窗口时: Here we go: Show me popover with html 并通过添加 CSS 类,例如: myClass { white
首先,问题的 fiddle :jsfiddle.net 我正在使用一个弹出窗口,它的内容是 html,一个类为“click_me”的按钮。我有 jquery 来监听对“click_me”的点击,它应该
当使用弹出窗口API时,我想,当轻关闭发生时,停止弹出窗口关闭,并运行自定义js从屏幕上删除弹出窗口。。有办法做到这一点吗?。我试着这么做,但没成功。。。
我有一个表格,每个单元格都有一个弹出框,如下例所示: 对 popover 的调用: 0, 'edited' : i.edited, 'final-installment' : i.last }" p
我的 Storyboard使用 UINavigationController(VC0),我使用 UIPopover 来加载新的 UIViewController (VC1)。从这个新的 UIViewC
这个问题在这里已经有了答案: iOS 13 - UIPopoverPresentationController sourceview content visible in the arrow (9
我是一名优秀的程序员,十分优秀!