获取对象集合中每一个元素的属性值。返回值为 null或undefined值得过滤掉。
datax.pluck(nodes,property)
Example: 在 li 对象集合属性 title ,输出在 .result 元素。
<!DOCTYPE html> <html> <head> <style> button {margin: 4px; cursor: pointer; } input { margin: 4px;color: blue; } </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> <div> <ul> <li title="1">10</li> <li title="2">20</li> <li title="3">30</li> <li title="4">40</li> </ul> <div class="result"></div> </div> <script> require(["skylark/query", "skylark/datax"], function($, datax) { var result = datax.pluck($("li"), "title").join("-"); $(".result").html("result is: " + result); }); </script> </body> </html>