How to build a conditional selector?
-
There is a set of elements with attributes of the form
id = 10
How do I construct a selector to select elements withid & gt; 10
?JavaScript Anonymous, Aug 12, 2020 -
https://jsfiddle.net/yarkov_aleksei/37w6bpr4/
<ul>
<li id="1"></li>
<li id="2"></li>
<li id="3"></li>
<li id="4"></li>
<li id="5"></li>
<li id="6"></li>
<li id="7"></li>
<li id="8"></li>
<li id="9"></li>
<li id="10"></li>
<li id="11"></li>
<li id="12"></li>
</ul>
const elements = [...document.querySelectorAll('li')];
console.log(elements.filter(li => +li.getAttribute('id') >= 10));Anonymous -
elem:not([id="1"]):not([id="2"]):not([id="3"]):not([id="4"]):not([id="5"]):not([id="6"]):not([id="7"]):not([id="8"]):not([id="9"]) {
...
}Anonymous -
possible with prefixes. it will work better this way.
you can walk through all the elements
Anonymous
3 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!