选择“prev”元素之后的所有同级元素,具有相同的父元素,并匹配筛选“同级”选择器。
finder.siblings(elm, selector)
Example: 查找每个含有 “selected” 样式的 p 的所有兄弟元素。
<!DOCTYPE html> <html> <head> <style> li { margin: 3px; padding: 3px; background: #EEEEEE; } li.hilight { background: yellow; } </style> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script> <script> require.config({ baseUrl: "./", packages: [{ name: "skylark", location: "../../../src/skylark" }, ] }); </script> </head> <body> <p>Hello</p> <p>Hello Again</p> <p class="selected">And Again</p> <p class="selected">Agin And Again</p> <script> require(["skylark/styler", "skylark/finder"], function(styler, finder) { finder.siblings(finder.find("p"), ".selected").forEach(function(node, index) { styler.css(node, "background", index % 2 === 0 ? "yellow" : "green"); }); }); </script> </body> </html>