Bootstrap Tutorial - Place popover right/left








The following code shows how to place popover right/left.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css">
<style type='text/css'>
.userInfo {<!--  ww  w . j  a v  a2 s.  co  m-->
  display: none;
}
.user {
  width: 50px;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $('.user').each(function() {
        var $this = $(this);
        $this.popover({
          trigger: 'hover',
          placement: 'right',//left
          html: true,
          content: $this.find('.userInfo').html()  
        });
    });
});
</script>
</head>
<body style='margin:30px'>
  <div class="user">
    user 1
    <div class="userInfo">
      <p>He likes pie!</p>
    </div>
  </div>
  <div class="user">
    user 2
    <div class="userInfo">
      <p>He likes cake!</p>
    </div>
  </div>
</body>
</html>

Click to view the demo