Convert string to uppercase in jQuery

toUpperCase method is used to convert a string into uppercase in jQuery. This functions returns a uppercase string. It will not modify the current variable, So you need to re-assign it.

var name = 'India';
alert(name.toUpperCase());

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 () {
        var name = 'India';
        alert(name.toUpperCase());
        alert(name);
      });
    });
  </script>
</head>
<body>
  <div>
    <button class="btnClick">Click</button>
  </div>
</body>
</html>
DISPLAY

1 comment :