Using an array with jQuery's .not() -


what i'm trying learn how use array .not() in jquery. code below. know why .item-ii not being excluded selection? in advance!

<ul class="level-1">   <li class="item-i">i</li>   <li class="item-ii">ii     <ul class="level-2">       <li class="item-a">a</li>       <li class="item-b">b         <ul class="level-3">           <li class="item-1">1</li>           <li class="item-2">2</li>           <li class="item-3">3</li>         </ul>       </li>       <li class="item-c">c</li>     </ul>   </li>   <li class="item-iii">iii</li> </ul> <script>     var temp = new array();     temp[0] = '.item-ii';     console.log(temp);     $('li').not(temp).css('background', 'red'); </script> 

if need exclude selectors in temp array, can do:

$('li').not(temp.join(',')).css('background', 'red'); 

for example if temp = ['.item-ii', '.item-i'], above equivalent to:

$('li').not('.item-ii,.item-i').css('background', 'red'); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -