温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么在Bootstrap弹出窗口中插入关闭按钮

发布时间:2022-03-24 09:57:48 来源:亿速云 阅读:247 作者:iii 栏目:web开发

这篇“怎么在Bootstrap弹出窗口中插入关闭按钮”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“怎么在Bootstrap弹出窗口中插入关闭按钮”文章吧。

答案:使用弹出框html选项

您可以使用Bootstrap弹出框的html选项将关闭按钮插入到弹出框内。此外,您可以利用该.popover('hide')方法在用户单击关闭按钮时隐藏弹出窗口。让我们尝试下面的示例,看看它是如何工作的:

例试试这个代码»

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Bootstrap Popover with Close Button</title>

<link rel="stylesheet" href="css/bootstrap.min.css">

<script src="js/jquery-3.5.1.min.js"></script>

<script src="js/popper.min.js"></script>

<script src="js/bootstrap.min.js"></script>

<script>

$(document).ready(function(){

    $('[data-toggle="popover"]').popover({

        placement : 'top',

        html : true,

        title : 'User Info <a href="#" class="close" data-dismiss="alert">&times;</a>',

        content : '<div class="media"><img src="images/avatar-tiny.jpg" class="mr-3" alt="Sample Image"><div class="media-body"><h6 class="media-heading">Jhon Carter</h6><p>Excellent Bootstrap popover! I really love it.</p></div></div>'

    });

    $(document).on("click", ".popover .close" , function(){

        $(this).parents(".popover").popover('hide');

    });

});

</script>

<style>

.wrapper{

     margin: 200px 150px 0;

    }

    .popover-title .close{

        position: relative;

        bottom: 3px;

    }

</style>

</head>

<body>

    <div class="wrapper">

        <button type="button" class="btn btn-primary" data-toggle="popover">Click Me</button>

    </div>

</body>

</html>

以上就是关于“怎么在Bootstrap弹出窗口中插入关闭按钮”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI