Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i use "z-index" as an css attribute selector?

Tags:

jquery

css

I need an attribute selector to match the first div element with an z-index and a value of 0. tTis is how i tried to get hands on the element,by using the css attribute selector syntax in jquery:

$("div[z-index='0']").first().doSomeJqueryStuff() ....

In my document there is an explicitly set z-index with a value of 0 on a div element, but the selector returns no result. Thanks for help!

like image 596
mcloud79 Avatar asked Oct 16 '25 14:10

mcloud79


2 Answers

You can apply attribute selector to inline style attribute (* means contains):

div[style*="z-index: 0"]
like image 55
Slava Avatar answered Oct 18 '25 11:10

Slava


Try

$('div').each(function({ 
    if ($('div').css('z-index') === '0') { // or ... === 0
        ....
    }
}
like image 43
Igor Konopko Avatar answered Oct 18 '25 13:10

Igor Konopko



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!