Load a Twitter Bootstrap Popover on Page load

前端 未结 6 1813
时光取名叫无心
时光取名叫无心 2021-01-13 20:33

I have the following BootStrap popover:



        
相关标签:
6条回答
  • 2021-01-13 21:03
    $(document).ready(function(){
    
    window.setTimeout("$('#example').popover('show')",1000);
    
    }
    

    It works for me. Try it out.

    0 讨论(0)
  • 2021-01-13 21:10

    Trigger the click event of that anchor tag using jQuery like

    $('[id$='example' ]').trigger("click");
    
    0 讨论(0)
  • 2021-01-13 21:13

    You forgot the quotes for show. This works:

    $(function () { 
      $("#example").popover('show');
    });
    

    Full example would be:

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <link href="css/bootstrap.min.css" rel="stylesheet">
      </head>
    
      <body>
        <a href='#' id='example' rel='popover' data-placement='right' data-content='Its so simple to create a tooltop for my website!' data-original-title='Twitter Bootstrap Popover'>HEY</a>
        <script src="js/jquery.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <script src="js/script.js"></script>
        <script>
          $(function() { 
            $("#example").popover('show');
          });
        </script>
      </body>
    </html>
    
    0 讨论(0)
  • 2021-01-13 21:16
    $("#example").popover({'placement':'bottom'}).popover('show');
    
    0 讨论(0)
  • 2021-01-13 21:18

    Run it after window is loaded like so:

    $(window).load(function(){
      $("#example").popover('show');
    });
    
    0 讨论(0)
  • 2021-01-13 21:24

    I found this way to be convenient:

    You can trigger the 'show' and set options in one fell swoop:

    $('#elementToPointAt').popover({
       'placement':'bottom',
       'content':'Look at me!'
    }).popover('show');
    
    0 讨论(0)
提交回复
热议问题