Can jQuery provide the tag name?
<p>I've got several elements on a HTML page which have the same class - but they're different element types.  I want to find out the tag name of the element as I loop over them - but .attr doesn't take "tag" or "tagname".</p>

<p>Here's what I mean.  Consider these elements on a page:</p>

<pre><code>&lt;h1 class="rnd"&gt;First&lt;/h1&gt;
&lt;h2 id="foo" class="rnd"&gt;Second&lt;/h2&gt;
&lt;h3 class="rnd"&gt;Third&lt;/h3&gt;
&lt;h4 id="bar" class="rnd"&gt;Fourth&lt;/h4&gt;
</code></pre>

<p>Now I want to run something like this to ensure that my elements all have an id if one wasn't already defined:</p>

<pre><code>$(function() {
  $(".rnd").each(function(i) {
    var id = $(this).attr("id");
    if (id === undefined || id.length === 0) {
      // this is the line that's giving me problems.
      // .attr("tag") returns undefined
      $(this).attr("id", "rnd" + $(this).attr("tag") + "_" + i.toString());
    }
  });
});
</code></pre>

<p>The result I would like would be that the H2 and H4 elements would then have an id of</p>

<pre><code>rndh2_1
rndh4_3
</code></pre>

<p>respectively.</p>

<p>Any ideas on how I can discover the tag name of the element represented by "this"?</p>
