Bootstrap Tutorial - Set modal header, footer and body








The following code shows how to set modal header, footer and body.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
<script type='text/javascript'>
$(window).load(function(){<!--from w  w w .  ja va 2  s. c  om-->
    $('.modal').modal();
    $('.action_compute').click(function() {
      if($('#username').val() == ""){
        $('#show_error').show();
        return false;
      }
    });
});
</script>
</head>
<body>
  <div class="modal hide fade" data-show="true">
    <div class="modal-header">Header</div>
    <div class="modal-body">
      <input type="text" id="username" />
    </div>
    <div class="modal-footer">
      <a href="#" class="btn" data-dismiss="modal">Close</a> <a href="#"
        class="btn btn-primary action_compute" data-dismiss="modal">Save
        changes</a>
    </div>
  </div>
</body>
</html>

Click to view the demo