1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>静态方法-holdReady</title> <style> div { height: 200px; width: 200px; background: red; margin-top: 10px; } </style> <script src="https://code.jquery.com/jquery-1.12.4.js" integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU=" crossorigin="anonymous"> </script>
<script> $(function () {
$("div:empty").css({ background: "black" });
$("div:contains('div')").css({ background: "blue" });
$("div:has('span')").css({ background: "yellow" });
$("div:parent").css({ background: "brown" }); }) </script> </head> <body> <div></div> <div>这是一个div</div> <div>这也是一个div</div> <div><span></span></div> </body> </html>
|