如何在弹出窗口中插入关闭按钮以进行引导 [英] How to insert close button in popover for bootstrap

查看:73
本文介绍了如何在弹出窗口中插入关闭按钮以进行引导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JS:

$(function(){
  $("#example").popover({
    placement: 'bottom',
    html: 'true',
    title : '<span class="text-info"><strong>title</strong></span> <button type="button" id="close" class="close">&times;</button>',
    content : 'test'
  })
  $('html').click(function() {
    $('#close').popover('hide');
  });
});

HTML:

<button type="button" id="example" class="btn btn-primary" ></button>

我写的代码没有显示弹出窗口.

i'm write your code isn't show your popup.

有人遇到这个问题吗?

推荐答案

您需要正确设置标记

<button type="button" id="example" class="btn btn-primary">example</button>

然后,一种方法是将close-handler附加到元素本身内,其工作原理如下:

Then, one way is to attach the close-handler inside the element itself, the following works :

$(document).ready(function() {
    $("#example").popover({
        placement: 'bottom',
        html: 'true',
        title : '<span class="text-info"><strong>title</strong></span>'+
                '<button type="button" id="close" class="close" onclick="$(&quot;#example&quot;).popover(&quot;hide&quot;);">&times;</button>',
        content : 'test'
    });
});  

这篇关于如何在弹出窗口中插入关闭按钮以进行引导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆