I'm wondering how to select an element that does not have a specific class using JavaScipt, not jQuery.
For example, I have this list:
<ul id="tasks">
<li class="completed selected">One Task</li>
<li>Two Task</li>
</ul>
and I select the completed task by:
var completeTask = document.querySelector("li.completed.selected");
But then I'm not sure how to select the list item that does not habe those classes.
Thanks!
This selects the second LI
element.
document.querySelector("li:not([class])")
or
document.querySelector("li:not(.completed):not(.selected)")
Example: http://jsfiddle.net/nickg1/T9nEk/