Get the type of the HTML element from a jquery object

html, javascript, jquery, types

Solution

$('.myElem').each(function () {
      var htmlType = $(this).prop('tagName') //Example
      console.log(htmlType);
});

Problem

Possible Duplicate: Get element type with jQuery Preamble: I'm Italian, sorry for my bad English. From an html code like this: ``` <input class="myElem" /> <input class="myElem" /> <div class="myElem"></div> <ul class="myElem"></ul> <input class="myElem" /> ``` is there a way to retrieve the html objects type? something like: ``` $('.myElem').each(function () { var htmlType = $(this).type() //Example console.log(htmlType); }); /* Log: * input * input * div * ul * input */ ```

Original source

Related problems