How can I see if an element is a "br"

javascript, jquery

Solution

How about just `$(element).is('br')`? For example:

<div class='tested' id='first'>
  <br class='tested' id='second' />
</div>

...
$('.tested').each(function() {
  var id = this.id;   
  if ($(this).is('br')) {
    console.log(id + ' is <br>');
  }
  else {
    console.log(id + ' is not <br>');
  }
});
// first is not <br>
// second is <br>​

Problem

How can I see if an element is a "br"? I have tried to get it via .attr("type") and .type() but it always returns undefined! It would work on a input or button but not on a br element.

Original source