fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <style> .siblings *{ display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px; margin: 15px; } </style> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"> </script> <script> $(document).ready(function(){ $("h2").nextUntil("h5",".1,.2,.3").css({"color":"red","border":"2px solid red"}); }); </script> </head> <body> <div style="width:500px;" class="siblings"> <div>parent <p>p</p> <span>span</span> <h2>h2</h2> <h3>h3</h3> <p>p</p> <p class="1">p类名为"1"</p> <p>p</p> <span class="2">span类名为"2"</span> <span class="2">span类名为"2"</span> <span>span</span> <h3 class="3">h3类名为"3"</h3> <h5>h5</h5> </div> </div> <p>在这个例子中,我们返回类名称“1”,“2”和“3”的所有元素,它是h2和h5之间的下一个兄弟元素。</p> </body> </html>
运行结果