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 ie 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"]');
$('#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>
:not()
这很好
$('#foo div').not('div[style*="transform"]');
console.log($('#foo').find('div:not([style*="transform"])').text());
<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);">111</div> <div id="2" style="background-color:black;">222</div> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.