获取或设置指定元素的属性值。
datax.attr(elm, name, value)
Example: 查找每个含有 <em> 中的 title 属性,并显示在 <div>。
<!DOCTYPE html> <html> <head> <style> em { color:blue; font-weight:bold; } div { color:red; } </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> Once there was a <em title="huge, gigantic">large</em> dinosaur... </p> The title of the emphasis is:<div></div> <script> require(["skylark/query","skylark/finder", "skylark/datax"], function(query,finder, datax) { var title=datax.attr(finder.find("em"), "title"); query("div").text(title); }); </script> </body> </html>