Not Selector
RUN
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Học lập trình miễn phí tại freetuts.net</title> <script src="https://freetuts.net/cnd/js/jquery/jquery-3.2.1.min.js"></script> </head> <body> <h1>Học lập trình miễn phí tại freetuts.net</h1> <p class="red">Đây là thẻ p class="red"</p> <div class="red">Đây là thẻ div class="red" </div> <div class="red">Đây là thẻ div class="red" </div> <span class="red">Đây là thẻ span class="red" </span> <p>Đây là thẻ p </p> <p class="red">Đây là thẻ p class="red"</p> <div class="no">Đây là thẻ div co class = not </div> <br> <button onclick="myFunction()">Click vào đây để xem kết quả</button> <script> function myFunction(){ $( ":not(.red)" ).css( "color", "blue"); $( ".red" ).css( "color", "red"); } </script> </body> </html>
PHÓNG TO