获得匹配元素集合中每个元素的子元素,选择器选择性筛选。
finder.children(node, selector)
Example: 查找含有 div 的所有子元素 p 改变其 color 颜色为 blue。
<!DOCTYPE html> <html> <head> <style> </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: "/lib/skylark" }, ] }); </script> </head> <body> <div> <span>Hello</span> <p >Hello Again</p> <div >And Again</div> <p>And One Last Time</p> </div> <script> require(["skylark/styler", "skylark/finder"], function(styler, finder) { finder.children(finder.find("div"), "p").forEach(function(node) { styler.css(node, "color", "blue"); }); }); </script> </body> </html>