Css: last-child

<div>
    

<p style="display:none">

</div>
css
p:last-child {
    color: red;
}

how can I make the last p element shown turn red

Css
Jun.18,2021

you can use jQuery to solve the problem that
directly selects the last p element to see if it is hidden. If it is hidden, then its previous element sets the style, otherwise it sets the style for this last element

<body>
    <div>
        

1

2

<p style="display:none">3

</div> </body> <script src="../echarts/jquery-3.1.0.min.js"></script> <script> if($("p:last").is(":hidden")){ $("p:last").prev().css("color","red") }else { $("p:last").css("color","red") } </script>

tried

p:not([style="display:block"]):last-child

but it has no effect

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5f71e-4581a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5f71e-4581a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?