Map each list item to uppercase

Description

The following code shows how to map each list item to uppercase.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--  w  ww .  j a va2 s .c o m-->
    var mappedItems = $("li").map(function(index) {
      var data = $("<li>").text($(this).text()).get(0);
      $(data).text($(data).text().toUpperCase());
      return data;
    });
    $("#results").append(mappedItems);
  });
</script>
</head>
<body>
<body>
  <ul>
    <li>ja va2s.com</li>
    <li>java 2s.com</li>
    <li>java2 s.com</li>
  </ul>
  <ul id="results">
  </ul>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities