Join tag name

Description

The following code shows how to join the tag name with map function.

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() {<!--from  w w  w  .j a  v a2s .  c  o m-->

    var list = $("div,p").map(function() {
      return this.tagName;
    }).get().join(", ");

    $("b").append(document.createTextNode(list));

  });
</script>

</head>
<body>
  <span>span</span>
  <p>p</p>
  <div>div</div>
  <b>bold</b>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities