Line break in Alert

You can use line break in alert message in jquery. You have to use \n where you want to break your line. It is very easy to break line in alert message. Please see the below example.

$('.btnClick').click( function(event){
  var result = 'jQuery ';
  result += '\nWith';
  result += '\nExample';
  alert(result);
});

CODE
<!DOCTYPE html>
<html>
<head>
  <title>jQuery With Example</title>
  <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(function () {
      $('.btnClick').click(function (event) {
        var result = 'jQuery ';
        result += '\nWith';
        result += '\nExample';
        alert(result);
      });
    });
  </script>
</head>
<body>
   <div>
    <button type="button" class="btnClick">Click</button>
  </div>
</body>
</html>
DISPLAY

No comments :

Please Give Your Feedback