Two consecutive pseudo selectors in jQuery don't work -



Two consecutive pseudo selectors in jQuery don't work -

i have issues selecting element jquery.

my html code comes downwards to:

<body> <p>dont mind me, sir</p> <p>select me please!</p> <p class="fabulous">so fab</p> </body>

with jquery:

$(document).ready(function(){ $('p:not(.fabulous):last-child').css({'background':'yellow'}); });

with selector $('p:not(.fabulous):last-child') trying select lastly element of parent (body, in case) not have class "fabulous". $('p:not(.fabulous)') select non-fabulous children of body why can not select lastly kid of leftover p elements? i'd much appreciate reply concerning behaviour of :last-child , :not(, or whatever selector misunderstood.

thanks!

:last-child selects elements last child of parent. lastly (<p>) kid of <body> <p class="fabulous">.

so, when p:not(.fabulous):last-child, asking <p> both lastly kid of parent and doesn't have class fabulous. no such element exists.

you'd need utilize $('p:not(.fabulous):last') in case.

jquery jquery-selectors css-selectors

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -