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.
Use the .tagName
or .nodeName
property.
Then compare the value to "BR"
.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With