Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find div which does not contain a specific property under specific attribute using CSS selector

I have the following situation:

<div id="foo">
   <div id="1" style="transform:translate3d(5px,5px,5px);"></div>
   <div id="2" style="background-color:black;"></div>
</div>

I want to find the div that does not have the 'transform' property i.e div with 'id = 2'.

I have tried the following, but it only selects the div having transform property, I want the exact opposite.

$('#foo').find('div[style*="transform"]');
like image 718
Biswas Khayargoli Avatar asked Dec 07 '25 17:12

Biswas Khayargoli


1 Answers

$('#foo').find('div:not([style*="transform"])').css('color','red')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="foo">
   <div id="1" style="transform:translate3d(5px,5px,5px);">1</div>
   <div id="2" style="background-color:black;">2</div>
</div>
  1. Use :not()
like image 130
guradio Avatar answered Dec 09 '25 05:12

guradio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!