george george - 17 days ago 4x
HTML Question

How to check if element has empty class?

I have a problem how to check if an element has empty class. I tried the code below, but doesn't work.

<nav id="main-nav" class="">
<li><a href=""><i class="fa fa-pencil-square-o" aria-hidden="true"></i> references</a></li>
<li><a href=""><i class="fa fa-male" aria-hidden="true"></i> about me</a></li>
<li><a href=""><i class="fa fa-wrench" aria-hidden="true"></i> abilities</a></li>

if ($('#main-nav:not([class])')){




You can merely do this:

var $elem = $('#main-nav');
if (!$elem.attr('class')) {

where I think that comments are not necessary...