获取或设置指定元素的当前值。
datax.attr(elm, value)
Example: 点击按钮时,在文本框中显示按钮的值。
<!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> <button>Feed</button> <button>the</button> <button>Input</button> </div> <input type="text" value="click a button" /> <script> require(["skylark/query","skylark/finder", "skylark/datax"], function(query,finder, datax) { query("button").click(function(){ var text =query(this).text(); datax.val(finder.find("input"),text) }); }); </script> </body> </html>